On 2024-04-25 9:29 p.m., Jacob Nolan via python-win32 wrote:
Hi all,
I've been having a reoccurring error across multiple windows installs
and python versions (3.9.*-3.11.*) when performing an install of a
python windows service.
This is the result of calling *python service_config.py install *on 3.9.5
The error is:
|*copying host exe
'E:\jacobnolan\installed_programs\programs\python39\lib\site-packages\win32\pythonservice.exe'
-> 'E:\*|*|jacobnolan||\installed_programs\programs\python39\pythonservice.exe'
Error installing service: The process cannot access the file because
it is being used by another process. (32)|*
For this system, this is not the first python service I have
installed. Additionally I've installed multiple services while other
python services have been running.
As stated in the error it looks to be the destination
pythonservice.exe is being used by another process, so can't be
replaced by my installing process.
Is there an approach to handle this?
* I'm not sure if pythonservice.exe really needs to be replaced each
install. I was contemplating looking at the service registration
process to determine if this step can be skipped.
The version of win32serviceutil you linked to isn't the latest, but I
assume you are talking about the copy made just after it prints
`print(f"copying host exe '{maybe}' -> '{correct}'")`? If so, as the
comments note, it doesn't really need to be updated each install, but
win32serviceutil takes a conservative approach because it's difficult to
know whether pywin32 might have been upgraded. The simplest way to avoid
that copy is to just remove the "maybe" file, leaving the "correct" file
in-place. I'd be fine with a patch that catches an error making the
copy, prints a warning but then continues. It might even be better if
that script tried to *move* the file - that should mean that upgrades
would still attempt to update it, but otherwise the file is only updated
once.
*
* Or if I should specify the location of the pythonservice.exe now
it is in the correct location to access the appropriate DLL's?
e.g win32serviceutil service use exeName?
o
https://github.com/mhammond/pywin32/blob/fcab71452cc8aefeb23b897a03753e34298d555f/win32/Lib/win32serviceutil.py#L215
In your other email you mentioned trying to use pyinstaller or similar
to package your service - in that world then you almost certainly will
want to point it at your own executable, although then you probably just
want sys.executable, in which case sys.frozen being set is all you need.
HTH,
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32