On Ubuntu 20.04, my pika consumer, which is created as a separate thread, breaks whenever I create a multiprocessing Queue after it. The behavior varies, but I get this error fairly often.
[ERROR]: Unexpected frame: <METHOD(['channel_number=1', 'frame_type=1', "method=<Basic.CancelOk(['...'])>"])>
I'm creating this Queue in the main thread that is also creating the PikaThread. I'm not using multiprocessing within the Thread. This issue does not occur when the multiprocessing Queue is created first. I've created a small sample that recreates this issue and can provide it if needed. Here's a small chunk that shows when I do and don't see the error. It seems to be related to multiprocessing.Queue. This may be an error on my end, but it seems like a strange issue. My assumption is that Pika isn't properly preventing other processes from using the socket it's using.
# Start the Pika thread before multiprocessing
def start_broken(self):
self.mh.start_thread()
self.q = multiprocessing.Queue(60)
process = multiprocessing.Process(target=self.foo)
process.start()
# Start the Pika thread after multiprocessing
def start_working(self):
self.q = multiprocessing.Queue(60)
process = multiprocessing.Process(target=self.foo)
process.start()
self.mh.start_thread()