Forum Archive

Celery import error

khilnani

I was able to pip install celery, but whem i try to import i get an error on import from the kombu package it depends on

from kombu.five import monotonic
  File "/private/var/mobile/Containers/Shared/AppGroup/6A6950F6-86D6-46AB-96BD-0E55FFAEC184/Pythonista3/Documents/site-packages/kombu/five.py", line 56, in <module>
    absolute_to_nanoseconds = CoreServices.AbsoluteToNanoseconds
  File "/var/containers/Bundle/Application/ACE4580A-901E-4AC9-8BA1-EEBF5F98373A/Pythonista3.app/Frameworks/PythonistaKit.framework/pylib/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/var/containers/Bundle/Application/ACE4580A-901E-4AC9-8BA1-EEBF5F98373A/Pythonista3.app/Frameworks/PythonistaKit.framework/pylib/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, AbsoluteToNanoseconds): symbol not found

the code at thr line with the issue is

if SYSTEM == 'Darwin' and ctypes is not None:
        from ctypes.util import find_library
        libSystem = ctypes.CDLL(find_library('libSystem.dylib'))
        CoreServices = ctypes.CDLL(find_library('CoreServices'),
                                   use_errno=True)
        mach_absolute_time = libSystem.mach_absolute_time
        mach_absolute_time.restype = ctypes.c_uint64
        absolute_to_nanoseconds = CoreServices.AbsoluteToNanoseconds  ##error##
        absolute_to_nanoseconds.restype = ctypes.c_uint64
        absolute_to_nanoseconds.argtypes = [ctypes.c_uint64]

I'm just trying to see if celery works at all when using sqlite, example

from celery import Celery
app = Celery('hello', broker='sqla+sqlite:///celerydb.sqlite')

Thanks!!!!!!

JonB

you could replace the last 3 lines with

absolute_to_nanoseconds = lambda t:1000*t

Thoughh there is a good chance something else will fail

khilnani

i could patch it but its a dependency of celery, so might become a bit wieldy soon.

i was wondering if anyone (or @omz ) knew why it might be failing and its something missing on iOS thats availablenon desktop

JonB

@khilnani said:
Because it uses depreciated functions, and more importantly functions which are not
supported on iOS. Technically, there might be a way to patch ctypes before you import to always return the same object, which you can then pre-patch to contain the faked method. On iOS dynamic loading is not allowed, so only static libraries that were compiled in are available, as well as NSBundles.