Message11652

Author tcdelaney
Recipients tcdelaney
Date 2017-11-08.01:34:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510104857.34.0.213398074469.issue2642@psf.upfronthosting.co.za>
In-reply-to
Content
I have an application which creates multiple PyScriptEngine instances on different threads. If multiple threads concurrently try to import I often get errors like:

Traceback (most recent call last):
  File ".\main.py", line 34, in <module>
    import threading
  File ".\lib\jython-standalone-2.7.1.jar\Lib\threading.py", line 88, in <module>
AttributeError: type object 'java.lang.Thread' has no attribute 'State'

and

Traceback (most recent call last):
  File ".\main.py", line 44, in <module>
    import gzip
  File ".\lib\jython-standalone-2.7.1.jar\Lib\gzip.py", line 10, in <module>
  File ".\lib\jython-standalone-2.7.1.jar\Lib\io.py", line 69, in <module>
  File ".\lib\jython-standalone-2.7.1.jar\Lib\_io.py", line 50, in <module>
ImportError: cannot import name DEFAULT_BUFFER_SIZE

Whilst I haven't been able to verify it, it appears to only be when importing Java classes.

By experimentation, if only a single thread is importing at a time the errors do not occur. As a workaround for my application I'm using a global import lock rather than an import lock per PySystemState, which seems to have resolved the issue. It's possible this is overkill and only part of the import process needs to be protected with a global lock.
History
Date User Action Args
2017-11-08 01:34:17tcdelaneysetrecipients: + tcdelaney
2017-11-08 01:34:17tcdelaneysetmessageid: <1510104857.34.0.213398074469.issue2642@psf.upfronthosting.co.za>
2017-11-08 01:34:16tcdelaneylinkissue2642 messages
2017-11-08 01:34:15tcdelaneycreate