Detect whether wineserver is fully started? Signal? File?

Sebastian Lackner sebastian at fds-team.de
Mon Jun 12 13:43:37 CDT 2017


On 12.06.2017 20:22, Sebastian M. Ernst wrote:
> Dear Wine developers,
> 
> I am working on a little Python module which is supposed to make use of
> Wine. The module has a dedicated class for managing its own
> wineserver-session with its own prefix. It allows me to control
> wineserver independently of the lifetime of any Windows executable I run
> on top of it and to quit it when my work is done.
> 
> Starting and stopping wineserver is no problem. However, what I can not
> figure out is how to determine when my wineserver is actually completely
> loaded, up and running. After all, the loading process requires quite a
> bit of time. Mainly due to my intention of preventing any (hard to
> debug) crashes and delays when running Windows executables, I want
> wineserver to be fully up & loaded before I run anything on top of it.
> The following code snipped illustrates the problem:
> 
> os.environ['WINEPREFIX'] = '/some/path'
> proc_wineserver = subprocess.Popen(
>    ['wineserver', '-f', '-p'], # run persistent in foreground
>    stdin = subprocess.PIPE,
>    stdout = subprocess.PIPE,
>    stderr = subprocess.PIPE,
>    shell = False
>    )
> time.sleep(1) # Placeholder *HACK*. BETTER SOLUTION?
> proc_somewinexe = subprocess.Popen(['wine some.exe'], shell = False)
> 
> As a temporary hack, for which I am seeking a replacement, I simply
> sleep for one second. This is odd on faster PCs and really not enough on
> somewhat older hardware (or with slow harddrives instead of SSDs) ...
> 
> Is there a signal I can catch or a file I can check (and wait for in a
> loop to appear) or anything else which would allow me a clean(er)
> solution? Or, alternatively, where in the Wine source code do I have to
> look for how the "wine" command does it (?) - looking for wineserver and
> firing one up if there is not one before any exe file is executed?
> 
> I recently posted a question in the Wine forum with similar content:
> https://forum.winehq.org/viewtopic.php?f=2&t=28967
> 
> Thanks for any advise,
> Sebastian
> 
> 

I would suggest to implement the same logic as used by Wine itself.
Basically, you would write a loop which periodically tries to connect to the
wineserver UNIX socket, until it finally succeeds. The socket will appear
at the following location (pseudocode):

info = os.stat(WINEPREFIX)
socket_path = os.path.join("/tmp", ".wine-%d" % os.getuid(), "server-%x-%x" % (info.st_dev, info.st_ino))

Best regards,
Sebastian



More information about the wine-devel mailing list