Skip to content

socket error at program exit when using MultiProcessConsumer #359

Closed
@alisaifee

Description

@alisaifee

As of bb68965 I'm seeing the following errors when the process exits when using MultiProcessConsumer:

 Exception socket.error: error(2, 'No such file or directory') in <bound method MultiProcessConsumer.__del__ of <MultiProcessConsumer group=uuid, topic=test-topic, consumers=2>> ignored

After some investigation it seems like accessing any of the objects created via multiprocessing.Manager in the __del__ method can cause problems as the Manager registers a multiprocessing finalise hook which can get called before __del__.

For example, if you run the following piece of code, you'll see the same error:

from multiprocessing import Manager
class Test(object):
    def __init__(self):
        self.manager = Manager()
        self.thing = self.manager.list()
    def __del__(self):
        self.thing.append(1)
t = Test()

A few related observations:

  • if auto_commit is False the error appears on process exit
  • if auto_commit is True the error doesn't appear as __del__ is not executed
  • if auto_commit is True and stop is called explicitly before the program exits, __del__ gets called on process exit and the exception occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions