Python과 함께 스레딩을 사용할 때 발생하는 코루틴 오류, RuntimeWarning: 코루틴 'time_messege'가 기다리지 않았습니다. (Coroutine error when using threading with python, RuntimeWarning: coroutine 'time_messege' was never awaited)


문제 설명

Python과 함께 스레딩을 사용할 때 발생하는 코루틴 오류, RuntimeWarning: 코루틴 'time_messege'가 기다리지 않았습니다. (Coroutine error when using threading with python, RuntimeWarning: coroutine 'time_messege' was never awaited)

Python으로 스레딩을 사용할 때 이 2가지 ** 코루틴 오류를 수정하는 방법을 알고 있습니다. 이것은... :

C:\Users\PC0\Anaconda3\lib\threading.py:870: RuntimeWarning: coroutine 'time_messege' was never awaited
  self._target(*self._args, **self._kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

하지만 여전히 작동하지 않습니다:

    async def on_ready(self) ‑> None:

        print("Logged on as {0}!".format(self.user))

        x = threading.Thread(target=time_messege) #Creo un thread independiente del main_thread
        x.start()

사실은 그 오류가 나타나는 이유를 더 이상 이해할 수 없다는 것입니다. 오류 2개.


참조 솔루션

방법 1:

time_message is an async function but when you start it, you aren't awaiting it. However I do not recommend using threading in your bot. time.sleep will lead to blocking in your bot.

discord.py has its own native extension for making task loops. You should check this out, as it is made to work with an asynchronous environment.

(by Electrisik VocalAy355)

참조 문서

  1. Coroutine error when using threading with python, RuntimeWarning: coroutine 'time_messege' was never awaited (CC BY‑SA 2.5/3.0/4.0)

#Python #Artificial-Intelligence #multithreading #python-3.x #discord






관련 질문

Python - 파일 이름에 특수 문자가 있는 파일의 이름을 바꿀 수 없습니다. (Python - Unable to rename a file with special characters in the file name)

구조화된 배열의 dtype을 변경하면 문자열 데이터가 0이 됩니다. (Changing dtype of structured array zeros out string data)

목록 목록의 효과적인 구현 (Effective implementation of list of lists)

for 루프를 중단하지 않고 if 문을 중지하고 다른 if에 영향을 줍니다. (Stop if statement without breaking for loop and affect other ifs)

기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)

사용자 지정 대화 상자 PyQT5를 닫고 데이터 가져오기 (Close and get data from a custom dialog PyQT5)

Enthought Canopy의 Python: csv 파일 조작 (Python in Enthought Canopy: manipulating csv files)

학생의 이름을 인쇄하려고 하는 것이 잘못된 것은 무엇입니까? (What is wrong with trying to print the name of the student?)

다단계 열 테이블에 부분합 열 추가 (Adding a subtotal column to a multilevel column table)

여러 함수의 변수를 다른 함수로 사용 (Use variables from multiple functions into another function)

리프 텐서의 값을 업데이트하는 적절한 방법은 무엇입니까(예: 경사하강법 업데이트 단계 중) (What's the proper way to update a leaf tensor's values (e.g. during the update step of gradient descent))

Boto3: 조직 단위의 AMI에 시작 권한을 추가하려고 하면 ParamValidationError가 발생합니다. (Boto3: trying to add launch permission to AMI for an organizational unit raises ParamValidationError)







코멘트