jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

Exception on script end #21

Closed ergorion closed 3 years ago

ergorion commented 3 years ago

Hi!

I'm using python-polarion (0.1.14) with python 3.8 under Win10 to access two different Polarion servers. Whenever my script ends, I get the following output:

Exception ignored in: <function Polarion.del at 0x000001D9CE0ADF70> Traceback (most recent call last): File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\polarion.py", line 43, in del File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\proxy.py", line 46, in call File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 127, in send File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 107, in post_xml File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 73, in post File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 590, in post File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 528, in request File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 448, in prepare_request File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 544, in merge_cookies File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 352, in update File "C:\Users\sa4238x\Anaconda3\lib\copy.py", line 92, in copy ImportError: sys.meta_path is None, Python is likely shutting down

It's not a real functional problem, still it's not nice. Thanx, Axel

jesper-raemaekers commented 3 years ago

Hi Axel,

I agree it's not nice and should be solved. However I'm having some trouble replicating this. I'm not sure the content of the script matters much. I though it maybe had something to do with the Polarion server, the server you use is probably slower (as mine is running on the local machine) so it may need more time when Python is shutting down. But I'm too unfamiliar with how Python shuts down to know if that might be an issue. I'll do some test with a different server soon and see if i find something. If you find something please let me know.

Jesper

ergorion commented 3 years ago

I'm comparing the two Polarion servers again, that I have access to: 1) older version of Polarion, soon to be migrated, ending the session works: `DEBUG:zeep.transports:HTTP Post to http://server-where-logoff-works/polarion/ws/services/SessionWebService: <?xml version='1.0' encoding='utf-8'?>

DEBUG:urllib3.connectionpool:http://server-where-logoff-works:80 "POST /polarion/ws/services/SessionWebService HTTP/1.1" 200 288 DEBUG:zeep.transports:HTTP Response from http://server-where-logoff-works/polarion/ws/services/SessionWebService (status: 200): -6150646902813261835 ` 2) newer version of Polarion, ending the session raises an error: `DEBUG:zeep.transports:HTTP Post to https://server-where-logoff-does-not-work/polarion/ws/services/SessionWebService: Exception ignored in: Traceback (most recent call last): File "C:\Users\sa4238x\Anaconda3\lib\site-packages\polarion\polarion.py", line 43, in __del__ File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\proxy.py", line 46, in __call__ File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\wsdl\bindings\soap.py", line 127, in send File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 107, in post_xml File "C:\Users\sa4238x\Anaconda3\lib\site-packages\zeep-4.0.0-py3.8.egg\zeep\transports.py", line 73, in post File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 590, in post File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 528, in request File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\sessions.py", line 448, in prepare_request File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 544, in merge_cookies File "C:\Users\sa4238x\Anaconda3\lib\site-packages\requests\cookies.py", line 352, in update File "C:\Users\sa4238x\Anaconda3\lib\copy.py", line 92, in copy ImportError: sys.meta_path is None, Python is likely shutting down `
ergorion commented 3 years ago

I have done some research on this error, and according to this website: https://github.com/SeleniumHQ/selenium/issues/8571 It might make sense to change the behaviour. Instead of closing the session in the del method, one could use the context handler protocol and use the methods enter and exit. This would probably also affect the init method.

What are your thoughts?

jesper-raemaekers commented 3 years ago

Nice find, there are some options here. The context handler is nice, but i think i would prefer trying the exit handler (https://docs.python.org/3/library/atexit.html) mainly because it does not require the user to think about the 'with' context handler.

jesper-raemaekers commented 3 years ago

Can you try that commit i made locally to see if polarion exitsts without exception?

ergorion commented 3 years ago

sorry have not come around to testing yet, will try next week.

ergorion commented 3 years ago

I haven't tested it extensively yet, but at first look this seems to solve the exception! Thanx!