-
Notifications
You must be signed in to change notification settings - Fork 127
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
Errors Related to Client.__del__ #125
Comments
I updated & Im still getting errors, i tried with 2 machines now 😥, can you guys test if the problem is fixed for you? |
Hey @mgmacias95, No, its still there, the errors im getting are kind of different than other people. |
Hello @0xRar, Can you post a traceback of the exact error you're getting? Thanks! Regards, |
Its the same traceback as the one up top but it changed a little because i upgraded to python 3.11, Exception ignored in: <function Client.__del__ at 0x0000000003A6EB60>
Traceback (most recent call last):
File "C:\Users\Isa\AppData\Roaming\Python\Python311\site-packages\vt\client.py", line 263, in __del__
File "C:\Users\Isa\AppData\Roaming\Python\Python311\site-packages\vt\client.py", line 301, in close
File "C:\Users\Isa\AppData\Roaming\Python\Python311\site-packages\vt\utils.py", line 22, in make_sync
File "C:\Program Files\Python311\Lib\asyncio\events.py", line 761, in get_event_loop_policy
File "C:\Program Files\Python311\Lib\asyncio\events.py", line 754, in _init_event_loop_policy
ImportError: sys.meta_path is None, Python is likely shutting down
sys:1: RuntimeWarning: coroutine 'Client.close_async' was never awaited just a declaimer everything works when using a specific function that interacts with vt-py, so its just a visual error Example1: |
Testing the following script: import vt
import asyncio
async def main():
c = vt.Client('xxx')
result = await c.scan_url_async('https://google.com/', wait_for_completion=True)
print(result)
await c.close_async()
asyncio.run(main()) With a python 3.11 docker image, I was unable to reproduce the error. Can you share some details about the script you're running? Thanks! Regards, |
I have similar issues. I tried Traceback (most recent call last):
File "C:\Users\yourn\PycharmProjects\Ransomware\ransomware\upload_files.py", line 93, in <module>
asyncio.run(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\yourn\PycharmProjects\Ransomware\ransomware\upload_files.py", line 86, in main
analyses = itertools.chain.from_iterable(await asyncio.gather(*worker_tasks))
File "C:\Users\yourn\PycharmProjects\Ransomware\ransomware\upload_files.py", line 48, in upload_hashes
analysis = await client.scan_file_async(file=f, wait_for_completion=True)
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\client.py", line 713, in scan_file_async
await self._get_session().post(
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\aiohttp\client.py", line 560, in _request
await resp.start(conn)
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\aiohttp\client_reqrep.py", line 894, in start
with self._timer:
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\aiohttp\helpers.py", line 720, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
Exception ignored in: <function Client.__del__ at 0x000001E424910D30>
Traceback (most recent call last):
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\client.py", line 263, in __del__
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\client.py", line 301, in close
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\utils.py", line 25, in make_sync
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\events.py", line 798, in new_event_loop
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\events.py", line 688, in new_event_loop
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\windows_events.py", line 315, in __init__
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 639, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down
sys:1: RuntimeWarning: coroutine 'Client.close_async' was never awaited
Exception ignored in: <function Client.__del__ at 0x000001E424910D30>
Traceback (most recent call last):
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\client.py", line 263, in __del__
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\client.py", line 301, in close
File "C:\Users\yourn\PycharmProjects\Ransomware\venv\lib\site-packages\vt\utils.py", line 25, in make_sync
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\events.py", line 798, in new_event_loop
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\events.py", line 688, in new_event_loop
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\windows_events.py", line 315, in __init__
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 639, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down I did little tweak like you suggested, like, async def upload_hashes(queue, apikey):
"""Uploads selected files to VirusTotal."""
return_values = []
async with vt.Client(apikey) as client:
while not queue.empty():
file_path = await queue.get()
with open(file_path, encoding='utf-8') as f:
analysis = await client.scan_file_async(file=f, wait_for_completion=True)
print(f'File {file_path} uploaded.')
queue.task_done()
return_values.append((analysis, file_path))
await client.close_async()
return return_values |
Hello @NaSangWon, Please, open a new issue next time. Otherwise it's quite tricky for us to manage (this issue is already closed). Looking at your code, you're closing the client twice: one by doing This is how the code should look: async def upload_hashes(queue, apikey):
"""Uploads selected files to VirusTotal."""
return_values = []
async with vt.Client(apikey) as client:
while not queue.empty():
file_path = await queue.get()
with open(file_path, encoding='utf-8') as f:
analysis = await client.scan_file_async(file=f, wait_for_completion=True)
print(f'File {file_path} uploaded.')
queue.task_done()
return_values.append((analysis, file_path))
return return_values Regards, |
Hey there,
my functions are working fine but when i run my script without my arguments i get errors,
any idea how to fix it?
The text was updated successfully, but these errors were encountered: