#๐ Startup dependency checks
82 messages ยท Page 1 of 1 (latest)
@graceful hare
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
I'm not convinced you need to check at all. If you don't check, and one of those programs is missing, what happens? I imagine you get an exception; you could simply document that exception.
I sadly dont get an exception because they run in an asyncio.ensure_future
ah.
I'm basically useless with async ... but doesn't the function that you run asynchronously get an exception?
that's hard to believe
surely it's doing something like subprocess.run, which will get an exception
if I use a try: except: block I can print out the exception
but if I dont do that it wont raise
when I said "get an exception" I did not mean "raise an exception that you can catch in the main thread or task"
well sure
How should that be handled then?
I imagine your task simply wants to start the program and let it run, and doesn't try to get information from it
yes
probably easiest to just check for the executable's existence in the main task before you start the async task
also I'm not convinced you need to start those subprocesses in their own tasks
theres many classes that are in play
and the end user can choose which to use based on what they want
I don't see how that's relevant
because then I'd have to put the checking in every single class
that's insane
what happens if somone tries to use some random class, and wireguard or openvpn aren't running?
presumably they get a name resolution error, or some network error like "couldn't connect to host"
then exceptions are raised in the tasks
sure
its about checking if openvpn or wireguard are even installed
I'm still not convinced you need to do that.
because it utilizes the directories /etc/openvpn and /etc/wireguard and obviously the binaries
How are you currently handling exceptions that the tasks raise?
that doesn't seem user-friendly
that means that if I call one of your API functions, it'll fail, but unless I happen to be examining the log, I won't even notice
apart from an exception such as wireguard or openvpn doesnt exist, theres no exceptions
it handles everything from openvpn or wireguard
it will automatically attempt to reconnect if disconnected, it handles invalid auth, if it cant connect etc etc
really? what are you doing that never fails? And can I get a job doing that ๐คฃ
so, we have a VPN handler and a VPN manager and a VPN rotator
the vpn handler spawns a subprocess and handles the output of openvpn/wireguard
I can only guess what those terms mean
the manager decides whether to restart the handler, make a new one or whatever
the rotator makes a new manager every x amount of hours to connect to a different vpn server
thats the components at play
they are initialized with a builder pattern
sounds vaguely suspicious but whatever
how is it suspicious?
I use it for my mullvad vpn because they dont really offer this kind of functionality
perhaps the only sensible thing is to have each API function handle the networking exception itself ๐ฆ
We're clearly outside my area of expertise
thats okay bro, thank you for assisting me tho ๐
i dont know
another idea: give up ๐ I'm mostly serious -- don't bother making the library responsible for starting openvpn and wireguard
well everything already works lol
just have the docs describe the symptoms of using the library without those programs running.
or what do you mean
im confused
also, what about doing the checks in a __init__.py file
or .... redesign the entire API so that instead of being just functions, they're all methods on some "my_api" class instance -- and that instance's constructor takes care of reporting the failure to start those programs
that might be ok. Usually I hate having files do anything "interesting" when they load, but this case might be worth making (wait for it) an exception ๐คฃ
๐คฃ yeah
I can make a VPNInitializer or whatever class, that first checks all the dependencies that exist on the system to see if everything is in order, and then if everything is in order, launch whatever it should launch
That might not be a bad idea
if I were you I'd ask again in a new thread, and I'll just shut up. Or ask in the #software-architecture channel
hmmm
this is an interesting question and I assume there are people who could help
I assume so too
I guess I'll do that
thanks a lot for taking the time out of your day to help me
I appreciate it big time ๐
๐
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Startup dependency checks