Got this report second-hand by email from the author of mwlib. Neither Ralf nor I have been able to reproduce it.
Hi Skip,
one of our users hit a bug in the lockfile module:
from: http://groups.google.com/group/mwlib/browse_thread/thread/fac4d193b2ccbe33
,---- | 010-10-22T10:04:24 mwlib.serve.info >> Creating directory '/var/cache/ | mw-serve/f0/f04461c3fcc1e139' | Traceback (most recent call last): | File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run | self.result = application(self.environ, self.start_response) | File "/usr/local/lib/python2.6/site-packages/mwlib-0.12.13-py2.6- | linux-i686.egg/mwlib/serve.py", line 180, in call | response = self.dispatch(request) | File "/usr/local/lib/python2.6/site-packages/mwlib-0.12.13-py2.6- | linux-i686.egg/mwlib/serve.py", line 207, in dispatch | lock = FileLock(self.get_collection_dir(collection_id)) | File "/usr/local/lib/python2.6/site-packages/mwlib-0.12.13-py2.6- | linux-i686.egg/mwlib/serve.py", line 43, in FileLock | return lockfile.FileLock(path, threaded=threaded) | File "build/bdist.linux-i686/egg/lockfile/init.py", line 171, in | init | TypeError: unsupported operand type(s) for &: 'NoneType' and 'long' `----
downgrading to 0.8 did fix the issue for him.
Cheers,
- Ralf
Comment #1
Posted on Jan 14, 2011 by Quick GiraffeI have a similar bug. Mac OS X 10.6, python 2.6
pf = None if not pidfile else lockfile.FileLock(pidfile)
File "/Library/Python/2.6/site-packages/lockfile-0.9.1-py2.6.egg/lockfile/init.py", line 171, in init self.tname = "-%x" % (ident & 0xffffffff)
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
Comment #2
Posted on Feb 22, 2011 by Swift WombatNot sure if this helps...
From my mac:
import threading threading.current_thread().name 'MainThread' threading.current_thread().ident
Looks like ident is None?
Comment #3
Posted on Feb 23, 2011 by Grumpy LionWhat version are you using? I'm pretty sure I fixed this awhile ago, though I'm on vacation right now so won't be able to check for a week or two.
Comment #4
Posted on Mar 7, 2011 by Quick CamelI'm using the latest trunk version and get the same error when I run a job on the sun grid engine.
File ".../lockfile.py", line 167, in init 0xffffffff) TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
Comment #5
Posted on Mar 7, 2011 by Grumpy LionPlease try branches/packages. Trunk is 0.8 which is no longer being developed. branches/packages is 0.9.x, the current focus of development.
Comment #6
Posted on May 13, 2011 by Massive Camelmarko-mac:goInvest marko$ python Python 2.6.1 (r261:67515, Aug 2 2010, 20:10:18) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import lockfile pid_file = lockfile.FileLock('marko.pid') Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.6/site-packages/lockfile/init.py", line 171, in init self.tname = "-%x" % (ident & 0xffffffff) TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
Same error here.
marko-mac:goInvest marko$ pip freeze | grep lockfile lockfile==0.9.1
Comment #7
Posted on Jun 16, 2011 by Happy DogHi, I've run into the same problem. For some reason, the thread is active and has the ident attribute and yet it is None. If you import thread and do thread.get_ident() it returns a value. I change the above line 171 in init,py to this to get around this bug:
ident = getattr(t, "ident", hash(t))
if ident == None: ident = hash(t)
self.tname = "-%x" % (ident & 0xffffffff)
Just check that ident is not None and use the hash value. Using getattr with a default value works only if the attribute doesn't exist, but in this case it does, it's just None.
Comment #8
Posted on Sep 28, 2011 by Massive RhinoConfirming that Comment 7 solves the problem. Can we please get this fixed upstream?
Comment #9
Posted on Feb 2, 2012 by Swift CamelI think this is caused by a bug in python itself. This bug made dummy threads and other threads not created with the threading module have an ident == None. See here for more: http://bugs.python.org/issue5632
Comment #10
Posted on Feb 5, 2012 by Quick OxComment 7 solves problem for me. Look forward to seeing it in the trunk.
Status: New
Labels:
Type-Defect
Priority-Medium