#๐Ÿ”’ Startup dependency checks

82 messages ยท Page 1 of 1 (latest)

hollow dockBOT
#

@graceful hare

Python help channel opened

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.

acoustic raft
#

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.

graceful hare
#

I sadly dont get an exception because they run in an asyncio.ensure_future

acoustic raft
#

ah.

#

I'm basically useless with async ... but doesn't the function that you run asynchronously get an exception?

graceful hare
#

sadly it doesnt

#

only when I ctrl+c the program

#

I get the exception

acoustic raft
#

that's hard to believe

#

surely it's doing something like subprocess.run, which will get an exception

graceful hare
#

if I use a try: except: block I can print out the exception

#

but if I dont do that it wont raise

acoustic raft
#

when I said "get an exception" I did not mean "raise an exception that you can catch in the main thread or task"

graceful hare
#

ah

#

yeah an exception gets created

#

but it doesnt get raised

#

in the main thread

acoustic raft
#

well sure

graceful hare
#

How should that be handled then?

acoustic raft
#

I imagine your task simply wants to start the program and let it run, and doesn't try to get information from it

graceful hare
#

yes

acoustic raft
#

probably easiest to just check for the executable's existence in the main task before you start the async task

graceful hare
#

heres the thing

#

theres many components in this library

acoustic raft
#

also I'm not convinced you need to start those subprocesses in their own tasks

graceful hare
#

theres many classes that are in play

#

and the end user can choose which to use based on what they want

acoustic raft
#

I don't see how that's relevant

graceful hare
#

because then I'd have to put the checking in every single class

acoustic raft
#

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"

graceful hare
#

then exceptions are raised in the tasks

acoustic raft
#

sure

graceful hare
#

its about checking if openvpn or wireguard are even installed

acoustic raft
#

I'm still not convinced you need to do that.

graceful hare
#

because it utilizes the directories /etc/openvpn and /etc/wireguard and obviously the binaries

acoustic raft
#

How are you currently handling exceptions that the tasks raise?

graceful hare
#
except Exception as e:
            self._logger.error(f"Error: '{e}'")
#

lol

acoustic raft
#

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

graceful hare
#

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

acoustic raft
graceful hare
#

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

acoustic raft
#

I can only guess what those terms mean

graceful hare
#

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

acoustic raft
#

sounds vaguely suspicious but whatever

graceful hare
#

how is it suspicious?

#

I use it for my mullvad vpn because they dont really offer this kind of functionality

acoustic raft
#

perhaps the only sensible thing is to have each API function handle the networking exception itself ๐Ÿ˜ฆ

#

We're clearly outside my area of expertise

graceful hare
#

thats okay bro, thank you for assisting me tho ๐Ÿ™ƒ

acoustic raft
#

another idea: give up ๐Ÿ™‚ I'm mostly serious -- don't bother making the library responsible for starting openvpn and wireguard

graceful hare
#

well everything already works lol

acoustic raft
#

just have the docs describe the symptoms of using the library without those programs running.

graceful hare
#

or what do you mean

#

im confused

#

also, what about doing the checks in a __init__.py file

acoustic raft
#

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

acoustic raft
graceful hare
#

๐Ÿคฃ yeah

graceful hare
#

That might not be a bad idea

acoustic raft
#

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

graceful hare
#

hmmm

acoustic raft
#

this is an interesting question and I assume there are people who could help

graceful hare
#

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 ๐Ÿ‘

acoustic raft
#

๐Ÿ’

hollow dockBOT
#
Python help channel closed

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