简体   繁体   中英

Using the original python packages instead of the jython packages

I am trying to create a hybrid application with python back-end and java GUI and for that purpose I am using jython to access the data from the GUI. I wrote code using a standard Python 3.7.4 virtual environment and it worked "perfectly". But when I try to run the same code on jython it doesn't work so it seems that in jython some packages like threading are overwritten with java functionality.

My question is how can I use the threading package for example from python but in jython environment?

Here is the error:

Exception in thread Thread-1:Traceback (most recent call last): File "/home/dexxrey/jython2.7.0/Lib/threading.py", line 222, in _Thread__bootstrap self.run() self._target(*self._args, **self._kwargs)

由于您已经解耦了应用程序,即使用python作为后端,使用java作为GUI,为什么不坚持使用它并在后端和前端之间建立通信层,则该层可以是REST或任何消息传递框架。

I think one issue you might be facing is that you are running on Jython 2.7.0 (~Python 2.7 compatible) but your code is written for CPython 3.7.4. So you might be facing Python 2 vs 3 issues.

The threading module in Jython is indeed different from CPython ie it is making use of JVM threading. However the intension is to be API compatible with Python 2.7 code so if it doesn't run that should be considered a bug.

My first suggestion would be try Jython 2.7.1 it contains many fixes over 2.7.0 https://www.jython.org/download however I suspect it still might not work. Check if your code runs on CPython 2.7 https://www.python.org/downloads/release/python-2716/ if it does then that sounds like a Jython bug. Open a ticket with details to reproduce at https://bugs.jython.org/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM