Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'dict' object has no attribute 'extend' bitrix24 #159

Closed
captainbanan opened this issue Apr 20, 2022 · 3 comments · Fixed by #160
Closed

AttributeError: 'dict' object has no attribute 'extend' bitrix24 #159

captainbanan opened this issue Apr 20, 2022 · 3 comments · Fixed by #160
Assignees

Comments

@captainbanan
Copy link

Я пытался выгрузить все хождения по стадиям через ручку "crm.stagehistory.list" через метод get_all()
мой код:
params = {'entityTypeId': 2, 'filter[>=CREATED_TIME]': '2022-04-01'} bitrix.get_all('crm.stagehistory.list', params)['result']['items']

на 2413 из ~120к все падает с ошибкой

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_30778/1773639979.py in <module>
      1 params = {'entityTypeId': 2, 'filter[>=CREATED_TIME]': '2022-04-01'}
----> 2 bitrix.get_all('crm.stagehistory.list', params)['result']['items']

~/analytics_env/lib/python3.8/site-packages/fast_bitrix24/bitrix.py in get_all(self, method, params)
     56         '''
     57 
---> 58         return self.srh.run(GetAllUserRequest(self, method, params).run())
     59 
     60     def get_by_ID(self, method: str, ID_list: Iterable,

~/analytics_env/lib/python3.8/site-packages/fast_bitrix24/srh.py in run(self, coroutine)
    102             loop = asyncio.get_event_loop()
    103 
--> 104         return loop.run_until_complete(self.run_async(coroutine))
    105 
    106     async def run_async(self, coroutine):

~/analytics_env/lib/python3.8/site-packages/nest_asyncio.py in run_until_complete(self, future)
     68                 raise RuntimeError(
     69                     'Event loop stopped before Future completed.')
---> 70             return f.result()
     71 
     72     def _run_once(self):

/usr/lib/python3.8/asyncio/futures.py in result(self)
    173         self.__log_traceback = False
    174         if self._exception is not None:
--> 175             raise self._exception
    176         return self._result
    177 

/usr/lib/python3.8/asyncio/tasks.py in __step(***failed resolving arguments***)
    278                 # We use the `send` method directly, because coroutines
    279                 # don't have `__iter__` and `__next__` methods.
--> 280                 result = coro.send(None)
    281             else:
    282                 result = coro.throw(exc)

~/analytics_env/lib/python3.8/site-packages/fast_bitrix24/srh.py in run_async(self, coroutine)
    109 
    110         async with self.handle_sessions():
--> 111             return await coroutine
    112 
    113     @asynccontextmanager

~/analytics_env/lib/python3.8/site-packages/fast_bitrix24/user_request.py in run(self)
    108 
    109         if self.first_response.more_results_expected():
--> 110             await self.make_remaining_requests()
    111             self.dedup_results()
    112 

~/analytics_env/lib/python3.8/site-packages/fast_bitrix24/user_request.py in make_remaining_requests(self)
    151             ).run()
    152 
--> 153         self.results.extend(remaining_results)
    154 
    155     def dedup_results(self):

AttributeError: 'dict' object has no attribute 'extend'

кажется, что по каким-то причинам иногда их API возвращает не массив, а что-то еще (словарь?) и все перестает работать

@leshchenko1979 leshchenko1979 self-assigned this Apr 20, 2022
@leshchenko1979
Copy link
Owner

Метод crm.stagehistory.list имеет нестандартный формат выдачи результатов и код get_all, который работал для всех других методов, для этого метода не сработал.

В ветке leshchenko1979/issue159 выложил правки -- можете проверить, что у вас с ними все работает?

@captainbanan
Copy link
Author

captainbanan commented Apr 20, 2022

да, все починилось, спасибо огромное
добавили вашу библиотеку во внутре-яндексовый PypI

@leshchenko1979
Copy link
Owner

Хаха, круто! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants