Почему этот скрипт Python зависает? асинхронное ожидание? Джанго-ОРМ? ⇐ Python
-
Anonymous
Почему этот скрипт Python зависает? асинхронное ожидание? Джанго-ОРМ?
I'm trying to learn to use this Python package for patent searching:
https://pypi.org/project/patent-client/
https://patent-client.readthedocs.io/en/latest
I'm following this example:
https://patent-client.readthedocs.io/en ... rship.html
When I paste the example into a simple script like below it hangs after execution. The print functions all execute as if the code worked properly but the script never terminates.
The patent_client emphasises async-await and Django-ORM compatible API. Is there something I need to add to get some async process to 'hang up'?? (sorry for wrong terminology)
from patent_client import USApplication, Assignment company_name = 'Luminopia' print("Company name: {}".format(company_name)) print("Getting applications") applicant_apps = USApplication.objects.filter(first_named_applicant=company_name).values_list('appl_id', flat=True).to_list() print("Found ", end='') print("{} applications".format(len(applicant_apps))) print("Getting assignments") assigned_apps = Assignment.objects.filter(assignee=company_name).explode('properties').values_list('appl_id', flat=True).to_list() print("Found ", end='') print("{} assignments".format(len(assigned_apps))) I added the print functions to verify where the script is hanging but the last line seems to execute fine. It just never returns to the command prompt.
Running in Python 3.10.
The terminal output from the script is:
Company name: Luminopia Getting applications Found 3 applications Getting assignments Found 4 assignments I tried adding exit() to the end of the program but to no avail.
I added print(*threading.enumerate(), sep = "\n" and the output is below. How do I tell these threads to terminate?
Источник: https://stackoverflow.com/questions/781 ... django-orm
I'm trying to learn to use this Python package for patent searching:
https://pypi.org/project/patent-client/
https://patent-client.readthedocs.io/en/latest
I'm following this example:
https://patent-client.readthedocs.io/en ... rship.html
When I paste the example into a simple script like below it hangs after execution. The print functions all execute as if the code worked properly but the script never terminates.
The patent_client emphasises async-await and Django-ORM compatible API. Is there something I need to add to get some async process to 'hang up'?? (sorry for wrong terminology)
from patent_client import USApplication, Assignment company_name = 'Luminopia' print("Company name: {}".format(company_name)) print("Getting applications") applicant_apps = USApplication.objects.filter(first_named_applicant=company_name).values_list('appl_id', flat=True).to_list() print("Found ", end='') print("{} applications".format(len(applicant_apps))) print("Getting assignments") assigned_apps = Assignment.objects.filter(assignee=company_name).explode('properties').values_list('appl_id', flat=True).to_list() print("Found ", end='') print("{} assignments".format(len(assigned_apps))) I added the print functions to verify where the script is hanging but the last line seems to execute fine. It just never returns to the command prompt.
Running in Python 3.10.
The terminal output from the script is:
Company name: Luminopia Getting applications Found 3 applications Getting assignments Found 4 assignments I tried adding exit() to the end of the program but to no avail.
I added print(*threading.enumerate(), sep = "\n" and the output is below. How do I tell these threads to terminate?
Источник: https://stackoverflow.com/questions/781 ... django-orm