Browse Source

ctypes might not be available on some platforms.

Ask Solem 15 years ago
parent
commit
8724819a5f
1 changed files with 5 additions and 2 deletions
  1. 5 2
      celery/utils.py

+ 5 - 2
celery/utils.py

@@ -8,8 +8,11 @@ from itertools import repeat
 from inspect import getargspec
 from functools import partial as curry
 from uuid import UUID, uuid4, _uuid_generate_random
-import ctypes
 import operator
+try:
+    import ctypes
+except ImportError:
+    ctypes = None
 
 noop = lambda *args, **kwargs: None
 
@@ -46,7 +49,7 @@ def gen_unique_id():
     For now this is provided by :func:`uuid.uuid4`.
     """
     # Workaround for http://bugs.python.org/issue4607
-    if _uuid_generate_random:
+    if ctypes and _uuid_generate_random:
         buffer = ctypes.create_string_buffer(16)
         _uuid_generate_random(buffer)
         return str(UUID(bytes=buffer.raw))