z/OS Tools & Language

Expand all | Collapse all

Python Threading

  • 1.  Python Threading

    Posted 04-27-2016 18:18

    I just installed Python and the thread module is missing. Is this expected? Other modules import successfully.

    $ echo $PYTHONHOME
    /usr/lpp/ported/bin
    $ echo $PYTHONPATH
    /usr/lpp/ported/lib/python2.7
    $ python -vvv
    # installing zipimport hook
    import zipimport # builtin
    # installed zipimport hook
    # trying /usr/lpp/ported/lib/python2.7/site.so
    # trying /usr/lpp/ported/lib/python2.7/sitemodule.so
    # trying /usr/lpp/ported/lib/python2.7/site.py
    # /usr/lpp/ported/lib/python2.7/site.pyc matches /usr/lpp/ported/lib/python2.7/site.py
    import site # precompiled from /usr/lpp/ported/lib/python2.7/site.pyc
    # trying /usr/lpp/ported/lib/python2.7/os.so
    # trying /usr/lpp/ported/lib/python2.7/osmodule.so
    # trying /usr/lpp/ported/lib/python2.7/os.py
    # /usr/lpp/ported/lib/python2.7/os.pyc matches /usr/lpp/ported/lib/python2.7/os.py
    import os # precompiled from /usr/lpp/ported/lib/python2.7/os.pyc
    import errno # builtin
    import posix # builtin
    # trying /usr/lpp/ported/lib/python2.7/posixpath.so
    # trying /usr/lpp/ported/lib/python2.7/posixpathmodule.so
    # trying /usr/lpp/ported/lib/python2.7/posixpath.py
    # /usr/lpp/ported/lib/python2.7/posixpath.pyc matches /usr/lpp/ported/lib/python2.7/posixpath.py
    import posixpath # precompiled from /usr/lpp/ported/lib/python2.7/posixpath.pyc
    # trying /usr/lpp/ported/lib/python2.7/stat.so
    # trying /usr/lpp/ported/lib/python2.7/statmodule.so
    # trying /usr/lpp/ported/lib/python2.7/stat.py
    # /usr/lpp/ported/lib/python2.7/stat.pyc matches /usr/lpp/ported/lib/python2.7/stat.py
    import stat # precompiled from /usr/lpp/ported/lib/python2.7/stat.pyc
    # trying /usr/lpp/ported/lib/python2.7/genericpath.so
    # trying /usr/lpp/ported/lib/python2.7/genericpathmodule.so
    # trying /usr/lpp/ported/lib/python2.7/genericpath.py
    # /usr/lpp/ported/lib/python2.7/genericpath.pyc matches /usr/lpp/ported/lib/python2.7/genericpath.py
    import genericpath # precompiled from /usr/lpp/ported/lib/python2.7/genericpath.pyc
    # trying /usr/lpp/ported/lib/python2.7/warnings.so
    # trying /usr/lpp/ported/lib/python2.7/warningsmodule.so
    # trying /usr/lpp/ported/lib/python2.7/warnings.py
    # /usr/lpp/ported/lib/python2.7/warnings.pyc matches /usr/lpp/ported/lib/python2.7/warnings.py
    import warnings # precompiled from /usr/lpp/ported/lib/python2.7/warnings.pyc
    # trying /usr/lpp/ported/lib/python2.7/linecache.so
    # trying /usr/lpp/ported/lib/python2.7/linecachemodule.so
    # trying /usr/lpp/ported/lib/python2.7/linecache.py
    # /usr/lpp/ported/lib/python2.7/linecache.pyc matches /usr/lpp/ported/lib/python2.7/linecache.py
    import linecache # precompiled from /usr/lpp/ported/lib/python2.7/linecache.pyc
    # trying /usr/lpp/ported/lib/python2.7/types.so
    # trying /usr/lpp/ported/lib/python2.7/typesmodule.so
    # trying /usr/lpp/ported/lib/python2.7/types.py
    # /usr/lpp/ported/lib/python2.7/types.pyc matches /usr/lpp/ported/lib/python2.7/types.py
    import types # precompiled from /usr/lpp/ported/lib/python2.7/types.pyc
    # trying /usr/lpp/ported/lib/python2.7/UserDict.so
    # trying /usr/lpp/ported/lib/python2.7/UserDictmodule.so
    # trying /usr/lpp/ported/lib/python2.7/UserDict.py
    # /usr/lpp/ported/lib/python2.7/UserDict.pyc matches /usr/lpp/ported/lib/python2.7/UserDict.py
    import UserDict # precompiled from /usr/lpp/ported/lib/python2.7/UserDict.pyc
    # trying /usr/lpp/ported/lib/python2.7/_abcoll.so
    # trying /usr/lpp/ported/lib/python2.7/_abcollmodule.so
    # trying /usr/lpp/ported/lib/python2.7/_abcoll.py
    # /usr/lpp/ported/lib/python2.7/_abcoll.pyc matches /usr/lpp/ported/lib/python2.7/_abcoll.py
    import _abcoll # precompiled from /usr/lpp/ported/lib/python2.7/_abcoll.pyc
    # trying /usr/lpp/ported/lib/python2.7/abc.so
    # trying /usr/lpp/ported/lib/python2.7/abcmodule.so
    # trying /usr/lpp/ported/lib/python2.7/abc.py
    # /usr/lpp/ported/lib/python2.7/abc.pyc matches /usr/lpp/ported/lib/python2.7/abc.py
    import abc # precompiled from /usr/lpp/ported/lib/python2.7/abc.pyc
    # trying /usr/lpp/ported/lib/python2.7/_weakrefset.so
    # trying /usr/lpp/ported/lib/python2.7/_weakrefsetmodule.so
    # trying /usr/lpp/ported/lib/python2.7/_weakrefset.py
    # /usr/lpp/ported/lib/python2.7/_weakrefset.pyc matches /usr/lpp/ported/lib/python2.7/_weakrefset.py
    import _weakrefset # precompiled from /usr/lpp/ported/lib/python2.7/_weakrefset.pyc
    import _weakref # builtin
    # trying /usr/lpp/ported/lib/python2.7/copy_reg.so
    # trying /usr/lpp/ported/lib/python2.7/copy_regmodule.so
    # trying /usr/lpp/ported/lib/python2.7/copy_reg.py
    # /usr/lpp/ported/lib/python2.7/copy_reg.pyc matches /usr/lpp/ported/lib/python2.7/copy_reg.py
    import copy_reg # precompiled from /usr/lpp/ported/lib/python2.7/copy_reg.pyc
    # trying /usr/lpp/ported/lib/python2.7/traceback.so
    # trying /usr/lpp/ported/lib/python2.7/tracebackmodule.so
    # trying /usr/lpp/ported/lib/python2.7/traceback.py
    # /usr/lpp/ported/lib/python2.7/traceback.pyc matches /usr/lpp/ported/lib/python2.7/traceback.py
    import traceback # precompiled from /usr/lpp/ported/lib/python2.7/traceback.pyc
    # trying /usr/lpp/ported/lib/python2.7/sysconfig.so
    # trying /usr/lpp/ported/lib/python2.7/sysconfigmodule.so
    # trying /usr/lpp/ported/lib/python2.7/sysconfig.py
    # /usr/lpp/ported/lib/python2.7/sysconfig.pyc matches /usr/lpp/ported/lib/python2.7/sysconfig.py
    import sysconfig # precompiled from /usr/lpp/ported/lib/python2.7/sysconfig.pyc
    # trying /usr/lpp/ported/lib/python2.7/re.so
    # trying /usr/lpp/ported/lib/python2.7/remodule.so
    # trying /usr/lpp/ported/lib/python2.7/re.py
    # /usr/lpp/ported/lib/python2.7/re.pyc matches /usr/lpp/ported/lib/python2.7/re.py
    import re # precompiled from /usr/lpp/ported/lib/python2.7/re.pyc
    # trying /usr/lpp/ported/lib/python2.7/sre_compile.so
    # trying /usr/lpp/ported/lib/python2.7/sre_compilemodule.so
    # trying /usr/lpp/ported/lib/python2.7/sre_compile.py
    # /usr/lpp/ported/lib/python2.7/sre_compile.pyc matches /usr/lpp/ported/lib/python2.7/sre_compile.py
    import sre_compile # precompiled from /usr/lpp/ported/lib/python2.7/sre_compile.pyc
    import _sre # builtin
    # trying /usr/lpp/ported/lib/python2.7/sre_parse.so
    # trying /usr/lpp/ported/lib/python2.7/sre_parsemodule.so
    # trying /usr/lpp/ported/lib/python2.7/sre_parse.py
    # /usr/lpp/ported/lib/python2.7/sre_parse.pyc matches /usr/lpp/ported/lib/python2.7/sre_parse.py
    import sre_parse # precompiled from /usr/lpp/ported/lib/python2.7/sre_parse.pyc
    # trying /usr/lpp/ported/lib/python2.7/sre_constants.so
    # trying /usr/lpp/ported/lib/python2.7/sre_constantsmodule.so
    # trying /usr/lpp/ported/lib/python2.7/sre_constants.py
    # /usr/lpp/ported/lib/python2.7/sre_constants.pyc matches /usr/lpp/ported/lib/python2.7/sre_constants.py
    import sre_constants # precompiled from /usr/lpp/ported/lib/python2.7/sre_constants.pyc
    # trying /usr/lpp/ported/lib/python2.7/_sysconfigdata.so
    # trying /usr/lpp/ported/lib/python2.7/_sysconfigdatamodule.so
    # trying /usr/lpp/ported/lib/python2.7/_sysconfigdata.py
    # /usr/lpp/ported/lib/python2.7/_sysconfigdata.pyc matches /usr/lpp/ported/lib/python2.7/_sysconfigdata.py
    import _sysconfigdata # precompiled from /usr/lpp/ported/lib/python2.7/_sysconfigdata.pyc
    # trying /usr/lpp/ported/lib/python2.7/sitecustomize.so
    # trying /usr/lpp/ported/lib/python2.7/sitecustomizemodule.so
    # trying /usr/lpp/ported/lib/python2.7/sitecustomize.py
    # trying /usr/lpp/ported/lib/python2.7/sitecustomize.pyc
    # trying /usr/lpp/ported/lib/python2.7/usercustomize.so
    # trying /usr/lpp/ported/lib/python2.7/usercustomizemodule.so
    # trying /usr/lpp/ported/lib/python2.7/usercustomize.py
    # trying /usr/lpp/ported/lib/python2.7/usercustomize.pyc
    import encodings # directory /usr/lpp/ported/lib/python2.7/encodings
    # trying /usr/lpp/ported/lib/python2.7/encodings/__init__.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/__init__module.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/__init__.py
    # /usr/lpp/ported/lib/python2.7/encodings/__init__.pyc matches /usr/lpp/ported/lib/python2.7/encodings/__init__.py
    import encodings # precompiled from /usr/lpp/ported/lib/python2.7/encodings/__init__.pyc
    # trying /usr/lpp/ported/lib/python2.7/encodings/codecs.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/codecsmodule.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/codecs.py
    # trying /usr/lpp/ported/lib/python2.7/encodings/codecs.pyc
    # trying /usr/lpp/ported/lib/python2.7/codecs.so
    # trying /usr/lpp/ported/lib/python2.7/codecsmodule.so
    # trying /usr/lpp/ported/lib/python2.7/codecs.py
    # /usr/lpp/ported/lib/python2.7/codecs.pyc matches /usr/lpp/ported/lib/python2.7/codecs.py
    import codecs # precompiled from /usr/lpp/ported/lib/python2.7/codecs.pyc
    import _codecs # builtin
    # trying /usr/lpp/ported/lib/python2.7/encodings/encodings.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/encodingsmodule.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/encodings.py
    # trying /usr/lpp/ported/lib/python2.7/encodings/encodings.pyc
    # trying /usr/lpp/ported/lib/python2.7/encodings/aliases.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/aliasesmodule.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/aliases.py
    # /usr/lpp/ported/lib/python2.7/encodings/aliases.pyc matches /usr/lpp/ported/lib/python2.7/encodings/aliases.py
    import encodings.aliases # precompiled from /usr/lpp/ported/lib/python2.7/encodings/aliases.pyc
    # trying /usr/lpp/ported/lib/python2.7/encodings/__builtin__.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/__builtin__module.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/__builtin__.py
    # trying /usr/lpp/ported/lib/python2.7/encodings/__builtin__.pyc
    # trying /usr/lpp/ported/lib/python2.7/encodings/ibm_1047.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/ibm_1047module.so
    # trying /usr/lpp/ported/lib/python2.7/encodings/ibm_1047.py
    # trying /usr/lpp/ported/lib/python2.7/encodings/ibm_1047.pyc
    Python 2.7.6 (default, Dec 17 2013, 04:28:09) [C] on os39023
    Type "help", "copyright", "credits" or "license" for more information.
    # trying readline.so
    # trying readlinemodule.so
    # trying readline.py
    # trying readline.pyc
    # trying /usr/lpp/ported/lib/python2.7/readline.so
    # trying /usr/lpp/ported/lib/python2.7/readlinemodule.so
    # trying /usr/lpp/ported/lib/python2.7/readline.py
    # trying /usr/lpp/ported/lib/python2.7/readline.pyc
    >>> import thread
    # trying thread.so
    # trying threadmodule.so
    # trying thread.py
    # trying thread.pyc
    # trying /usr/lpp/ported/lib/python2.7/thread.so
    # trying /usr/lpp/ported/lib/python2.7/threadmodule.so
    # trying /usr/lpp/ported/lib/python2.7/thread.py
    # trying /usr/lpp/ported/lib/python2.7/thread.pyc
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named thread
    >>> import threading
    # trying threading.so
    # trying threadingmodule.so
    # trying threading.py
    # trying threading.pyc
    # trying /usr/lpp/ported/lib/python2.7/threading.so
    # trying /usr/lpp/ported/lib/python2.7/threadingmodule.so
    # trying /usr/lpp/ported/lib/python2.7/threading.py
    import threading # from /usr/lpp/ported/lib/python2.7/threading.py
    # can't create /usr/lpp/ported/lib/python2.7/threading.pyc
    # trying thread.so
    # trying threadmodule.so
    # trying thread.py
    # trying thread.pyc
    # trying /usr/lpp/ported/lib/python2.7/thread.so
    # trying /usr/lpp/ported/lib/python2.7/threadmodule.so
    # trying /usr/lpp/ported/lib/python2.7/thread.py
    # trying /usr/lpp/ported/lib/python2.7/thread.pyc
    #   clear[1] _sys
    #   clear[2] __name__
    #   clear[2] __doc__
    #   clear[2] __file__
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lpp/ported/lib/python2.7/threading.py", line 6, in <module>
        import thread
    ImportError: No module named thread
    >>> import test
    # trying test.so
    # trying testmodule.so
    # trying test.py
    # trying test.pyc
    import test # directory /usr/lpp/ported/lib/python2.7/test
    # trying /usr/lpp/ported/lib/python2.7/test/__init__.so
    # trying /usr/lpp/ported/lib/python2.7/test/__init__module.so
    # trying /usr/lpp/ported/lib/python2.7/test/__init__.py
    import test # from /usr/lpp/ported/lib/python2.7/test/__init__.py
    # can't create /usr/lpp/ported/lib/python2.7/test/__init__.pyc
    >>>


  • 2.  RE: Python Threading

    Posted 04-28-2016 16:09

    The python 2 documentation mentions that threading is an optional module that may not exist on all platforms.

    The module is optional. It is supported on Windows, Linux, SGI IRIX, Solaris
    2.x, as well as on systems that have a POSIX thread (a.k.a. “pthread”)
    implementation. For systems lacking the thread module, the
    dummy_thread module is available. It duplicates this module’s interface
    and can be used as a drop-in replacement.

    I will check with our open source tools team to see if this module is expected to be present or not, and get a comment for this. Thank you.



  • 3.  RE: Python Threading

    Posted 04-29-2016 11:22

    Indeed we have not ported the threading module. It is on our roadmap and we will eventually get to it but I do not yet have a date by which it will be released.