-
Notifications
You must be signed in to change notification settings - Fork 22
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
login reference count with context manager #14
Comments
Can you explain why you need this a little better. Maybe I can fix it so that it works for what you need if I understand the issue better. |
Hi @p4r4n0y1ng , my problem is following. On each call, where do I need the fmg instance I do login/using context manager. There are some functions which could be called directly or as result of another call. If the function is called directly, there is no problem. if is called as nested, the context manager will do the second time login. I could not create session on server start, since if the fortimanager is not available, the server failed to start. Or the session could expiry and there is not automatic renewal. I have similar issue with the IPAM client library. I do not understand the magic with regards |
I still don't see this as an issue. Please show me the code or a piece of real code that is causing issues so I can better determine if this is something that can be fixed or if it's best just to not use the context and control the login and logout yourself. |
the code is in the issue description. This is very simple example, my code is more complex, but it illustrates the usage. I need to login on first function call, so oin each function I use contex manager for this purpose.
or
result is
|
Again, why...? Just login and send the reference around. why do you need the multiple context calls and multiple logins. If you want to check it for session livelihood, you can (str is overridden for that if you want) and if it's not logged in, call the login function again...I don't see the issue....your code is there certainly but you're not explaining why you have to do nested contexts. Put pyFMG in a class and make your own singleton won't work? |
@p4r4n0y1ng OK, I rewrite the code, no need this any more |
Hi,
Would like to have some kind of reference counter for login/logout.
For simplicity I provide code that not work, but in my case it's a little bit more complex
The text was updated successfully, but these errors were encountered: