I have a Python script which uses RabbitMQ and the pika module to receive messages from clients. Given a message "enable", the script is required to run a method in a new thread, and given a message "disable", the thread that started with "enable" now needs to terminate.
However, every time a message is received, pika triggers a callback method which I assume runs in a new thread, and once the message is done being handled, the callback thread terminates.
In that case, two callbacks in different threads start and terminate another thread. I noticed that when I attempt to join(), I get:
File "/usr/lib/python2.7/threading.py", line 940, in join
raise RuntimeError("cannot join current thread")
Is there some rule that the same thread that starts another thread also has to join() it? Or am I misunderstanding the problem?
I initially thought the error means a thread is trying to join itself, but I'm convinced that's not the case, and the issue started ever since two different threads started creating and terminating the same thread.