Har
Har

Reputation: 3918

multiprocessing Event subclassing

I have attempted to subclass Event from multiprocessing, but it doesn't work, does anyone know why?

from multiprocessing import Event

class MyEvent(Event):
     def __init__(self):
         self.__init__()

I get the following error message:

TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str

Upvotes: 2

Views: 226

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600041

multiprocessing.Event is actually a function that returns an instance of multiprocessing.synchronize.Event. You would need to subclass that class directly.

(Note also that your __init__ method is very strange, and will cause an infinite recursion. I suspect you meant to call super(); but if you are not actually doing anything in that method, it is better not to define it at all.)

Upvotes: 3

Related Questions