简体   繁体   English

使用原始的python软件包而不是jython软件包

[英]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. 我正在尝试使用python后端和Java GUI创建一个混合应用程序,为此,我正在使用jython从GUI访问数据。 I wrote code using a standard Python 3.7.4 virtual environment and it worked "perfectly". 我使用标准的Python 3.7.4虚拟环境编写了代码,并且“完美”地工作了。 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. 但是,当我尝试在jython上运行相同的代码时,它不起作用,因此似乎在jython中,某些线程之类的包被Java功能覆盖了。

My question is how can I use the threading package for example from python but in jython environment? 我的问题是如何在jython环境中使用来自python的线程包?

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) 线程Thread-1:Traceback中的异常(最近一次调用最近):文件_Thread__bootstrap self.run()self._target(* self。)中的文件“ /home/dexxrey/jython2.7.0/Lib/threading.py”,第222行。 _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. 我认为您可能面临的一个问题是,您正在Jython 2.7.0(〜Python 2.7兼容)上运行,但是您的代码是为CPython 3.7.4编写的。 So you might be facing Python 2 vs 3 issues. 因此,您可能会遇到Python 2 vs 3问题。

The threading module in Jython is indeed different from CPython ie it is making use of JVM threading. Jython中的线程模块确实不同于CPython,即它正在使用JVM线程。 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. 但是,此意图是要与Python 2.7代码兼容的API,因此,如果它不运行,则应视为错误。

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. 我的第一个建议是尝试Jython 2.7.1,它包含2.7.0版的许多修复程序https://www.jython.org/download,但是我怀疑它仍然可能无法正常工作。 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. 检查您的代码是否在CPython 2.7上运行https://www.python.org/downloads/release/python-2716/如果这样做,则听起来像是Jython错误。 Open a ticket with details to reproduce at https://bugs.jython.org/ 打开带有详细信息的票证以在https://bugs.jython.org/复制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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