osbrain icon indicating copy to clipboard operation
osbrain copied to clipboard

Find a way to pass `config` around processes on Windows

Open ocaballeror opened this issue 7 years ago • 1 comments

Related to #255

Since Windows can't fork to create new processes, and it must use spawn, global variables such as config are not being copied to child processes. We should find a way to work around this, otherwise config basically becomes a constant, and that's not the expected behaviour.

Maybe we should pass it as an extra attribute to AgentProcess and NameserverProcess?

ocaballeror avatar Feb 27 '18 13:02 ocaballeror

I have been playing around with this, with variable amounts of success.

I got the test_agent_bind_transport_global to work by passing the config as a parameter to the Agent constructor, and then using it to set the global variable inside __init__.

The linger test, though, I couldn't get to pass, and I'm still not sure why. One thing I noticed about the other one was that, when launching a windows process, __init__.py is executed again (which doesn't happen after a fork), and that overrides the config dictionary, so that's something to keep in mind.

In the end, I'm thinking the issue has something to do with the way and, specifically, the order in which python imports different modules, because even though Agent.close_all() and get_linger() are executed in the same process, they read different values for config['LINGER'], which is what eventually makes the thing fail.

All the progress (mostly hacks) I've made is saved in my config branch.

ocaballeror avatar Apr 06 '18 13:04 ocaballeror