I'm using the multiprocessing module on Python3.4. For some reason I get the following error using isinstance():
>>> from multiprocessing import Lock
>>> isinstance(Lock(), Lock)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: isinstance() arg 2 must be a type or tuple of types
Whereas if I try the same with datetime
it works
>>> from datetime import datetime, timedelta
>>> isinstance(datetime.now(), datetime)
True
What I tried:
When I check see how Lock shows up in the console vs datetime and I get the following:
>>> Lock()
<Lock(owner=None)>
>>> Lock
<bound method DefaultContext.Lock of <multiprocessing.context.DefaultContext object at 0x00000000039810B8>>
>>> datetime.now()
datetime.datetime(2016, 6, 13, 11, 24, 12, 573712)
>>> datetime
<class 'datetime.datetime'>
but following Lock to its definition shows that it's indeed a class.
class Lock(object):
def acquire(self, blocking=True, timeout=-1):
pass
def release(self):
pass
So why does the console call it a "bound method". How can I use isinstance() on a Lock instance?