-
Notifications
You must be signed in to change notification settings - Fork 26
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
logout error in destructor of my class #80
Comments
It's an import error and hard to tell without seeing the full project. Maybe you have shadowed If I see correctly, the exception is raised by the requests library and then re-raised by python-fmrest. You could check what |
Here is the simplified working code for you to replicate this problem. class FileMaker:
def __init__(self, fm_server_url, fm_user, fm_password, fm_db_name):
layout = "GLOBAL"
self.fms = fmrest.Server(
fm_server_url,
user=fm_user,
password=fm_password,
database=fm_db_name,
layout=layout,
verify_ssl=True,
api_version="v1",
)
self.fms.login()
def __del__(self):
self.fms.logout()
fm_server_url = ""
fm_user = ""
fm_password = ""
fm_db_name = ""
fm = Filemaker(fm_server_url, fm_user, fm_password, fm_db_name) |
I believe the issue is that you're calling the logout during shutdown of the interpreter when some imports have already been cleared (when I would suggest using the context manager of fmrest (or a context manager for your wrapper):
This would also handle the logout for you. |
I have created a wrapper around python-fmrest where I have:
def init(self, fm_server_url, fm_user, fm_password, fm_db_name):
self.fms.login()
def del(self):
self.fms.logout()
I get this error:
Exception ignored in: <function FileMaker.del at 0x118b38ca0>
Traceback (most recent call last):
File "filemaker_utils.py", line 21, in del
File ".venv/lib/python3.10/site-packages/fmrest/server.py", line 217, in logout
File ".venv/lib/python3.10/site-packages/fmrest/server.py", line 925, in _call_filemaker
File ".venv/lib/python3.10/site-packages/fmrest/utils.py", line 14, in request
fmrest.exceptions.RequestException: Request error: import of time halted; None in sys.modules
The text was updated successfully, but these errors were encountered: