peeringdb / peeringdb-py

PeeringDB python client
BSD 2-Clause "Simplified" License
89 stars 22 forks source link

Trying to do a full sync results in a django error message #47

Closed dcorbe closed 4 years ago

dcorbe commented 4 years ago

(pdbvenv) PS C:\Users\corbe\Projects> peeringdb sync Syncing to https://www.peeringdb.com/api Updating resources: org fac net ix ixfac ixlan ixpfx netfac netixlan poc Fetching & updating all: org Updates to be processed: 19372 Traceback (most recent call last): File "c:\users\corbe\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\corbe\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\corbe\Projects\pdbvenv\Scripts\peeringdb.exe__main.py", line 7, in File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb\cli.py", line 62, in main return handler(config=cfg, vars(options)) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb\commands.py", line 20, in _wrapped r = func(*a, *k) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb\commands.py", line 219, in handle client.update_all(rs) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_update.py", line 66, in update_all self._atomic_update(lambda: ctx.sync_resource(r, since=since)) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_update.py", line 78, in _atomic_update sync_func() File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_update.py", line 66, in self._atomic_update(lambda: ctx.sync_resource(r, since=since)) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_tasks_async.py", line 65, in _wrapped return loop.run_until_complete(func(a, k)) File "c:\users\corbe\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 616, in run_until_complete return future.result() File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_tasks_async.py", line 41, in _wrapped item = gen.send(r) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_update.py", line 187, in sync_row obj, fetched, dangling = _sync.initialize_object(B, res, row) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb_sync.py", line 47, in initialize_object obj = B.get_object(B.get_concrete(res), row['id']) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\peeringdb\backend.py", line 26, in wrapped return fn(*args, *kwargs) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django_peeringdb\client_adaptor\backend.py", line 102, in get_object return concrete.objects.get(pk=id) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(args, **kwargs) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\query.py", line 425, in get num = len(clone) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\query.py", line 269, in len self._fetch_all() File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\query.py", line 1303, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\query.py", line 53, in iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\db\models\sql\compiler.py", line 1152, in execute_sql cursor = self.connection.cursor() File "c:\users\corbe\projects\pdbvenv\lib\site-packages\django\utils\asyncio.py", line 24, in inner raise SynchronousOnlyOperation(message) django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

dcorbe commented 4 years ago

Incidentally this just kind of 'just works' from the peeringdb docker container, so I'm not sure how big of an issue this is.

vegu commented 4 years ago

This error was a compatibility issue with django3 andthe latest release of peeringdb-py and django-peeringdb should fix this, closing - please reopen if issue still there.