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

Совместимость с Django #209

Open
dka58 opened this issue Dec 3, 2022 · 2 comments
Open

Совместимость с Django #209

dka58 opened this issue Dec 3, 2022 · 2 comments

Comments

@dka58
Copy link

dka58 commented Dec 3, 2022

Trace: https://pastebin.com/6Eiwuzy7

Не могу пока понять в чём проблема. Структура такая, в файлах:

# bitrix_connector.py
from fast_bitrix24 import Bitrix

webhook = "https://test.bitrix24.ru/rest/1/1234567890/"
BitrixConnector = Bitrix(webhook, verbose=False, respect_velocity_policy=True)
b = BitrixConnector

class BitrixCalls:
    '''
    '''
   def get_all_tasks_by_project_id(self, id: str) -> Union[list, dict]:
        return b.get_all("tasks.task.list", {"filter": {"=GROUP_ID": id}})

   def get_task_by_id(self, id: str) -> dict:
        """
        Returns task or None if not found
        """
        try:
            res = b.get_all("tasks.task.get", {"taskId": id})
            return res if res else None
        '''
        '''
        '''
bcall = BitrixCalls()
# models.py
from apps.bitrix.bitrix_connector import bcall

class Model(models.Model)
    """
    """
    """
   def update_task_from_bitrix(self):
        task = bcall.get_task_by_id(self.bitrix_id)["task"]

Тут не работает. Падает эта ошибка или переодически RuntimeError: Event loop is closed

А тут, всё прекрасно работает:

# services.py
from .bitrix_connector import bcall

class BitrixUpdateOrCreateService:
    """
    """
    """
   @staticmethod
    def update_or_create_tasks() -> int:
        tasks = bcall.get_all_tasks_by_project_id(project.bitrix_id)
@leshchenko1979
Copy link
Owner

  1. Надо покрутить тесты в Python 3.11. Честно говоря, пока не тестировал, посмотрим.
  2. А в какой среде все это запускается? Я вижу по трейсам, что это локальный комп, но там еще над fast_bitrix какие-то threads?
  3. Пробовали ли использовать асинхронный клиент BitrixAsync?

@dka58
Copy link
Author

dka58 commented Dec 5, 2022 via email

@leshchenko1979 leshchenko1979 changed the title RuntimeError: Timeout context manager should be used inside a task Совместимость с Django Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants