This week, I ran into a strange problem with a multi-threading Python case from a partner.
def foo():
for i in range(10):
print i
# call from main thread
foo()
# call from separate thread
import threading
mythread = threading.Thread(target=foo)
mythread.start()
The output is quite strange:
0
1
2
3
4
5
6
7
8
9
9
8
7
6
5
4
3
2
1
0
The child thread's output order is reversed, how did that happen?
After spending some time with our engineers, we found that Maya will treat the higher priority queue as a stack for better performance. The Python I/O output is considered as a high priority event and it is in the high priority idle queue.
If you are using multi-threading in your code or idle queue, you may want to take this into consideration.
Comments
You can follow this conversation by subscribing to the comment feed for this post.