Multithreading in PythonScript Forum › Forums › Visual Components 4.1 › Python Programming in VC › Multithreading in PythonScript This topic contains 3 replies, has 3 voices, and was last updated by BaiYang 3 weeks, 1 day ago. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts 19/09/2019 at 09:35 #17149 BaiYangParticipant Hello, i have wrote a multithreading program in PythonScript using “thread” module,but it shows a error dialog as follow: the code as follow: from vcScript import * import thread def f1(): while True: delay(1) print(‘————-thread1—————‘) print(‘thread1’) def f2(): while True: delay(1) print(‘————-thread2—————‘) print(‘thread2’) def OnRun(): thread.start_new_thread(f1,(‘thread1’,1)) thread.start_new_thread(f2,(‘thread2’,2)) delay(100) Does anyone know how to solve this problem? Thanks for your help. You need to login in order to like this post: click here 19/09/2019 at 10:56 #17158 CaptainFeatureParticipant Hy, i think Multithreading is not supported in Python-Scripts of components… Why do you need it? Regards You need to login in order to like this post: click here 19/09/2019 at 11:01 #17153 deadeyeParticipant I guess you’re using the module thread, which should not exposed to the user. In normal CPython 2.7 it is a very low level implementation and should not be used (Python 2.7 aswell). Here is an example from Stackless Python 2.7. This implementation of Python is used in VC. The usage differs a little bit. You can have “channels” which are a kind of message queue and schedulers. https://stackless.readthedocs.io/en/2.7-slp/library/stackless/threads.html Try as first if the provided examples are working. You need to login in order to like this post: click here 23/09/2019 at 03:41 #17232 BaiYangParticipant @ Captain_Feature I want to execute two parallel tasks in one python script,because the two tasks share the same resource . @deadeye Thanks for your reply,i will have a try. You need to login in order to like this post: click here Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic.