Can't start event daemon on windows any longer ("incorrect function")


after some hiccups with windows I am trying to get the event daemon to work again. It’s the same machine that had been running it just fine for quite some time, but I had to remove the service and add it again for certain reasons.
When I test the daemon framework in an eleveated powershell it works just fine.

However, when I try to start the service via the Windows Services UI I get an error saying this:

When I check the system event viewer all I get is this very unhelpful message:

To remove the daemon I used an elevated powershell and ran this command:

D:\Python27\python.exe D:\SG_Event_Daemon\src\ remove

Then I reinstalled it via this command:

D:\Python27\python.exe D:\SG_Event_Daemon\src\ install

When I run it in the foreground like this it works fine:

D:\Python27\python.exe D:\SG_Event_Daemon\src\ foreground

Same when I use debug like so:

D:\Python27\python.exe D:\SG_Event_Daemon\src\ debug

When I try to start it via the powershell instead of the UI it says it is starting the service but it actually fails to start.

What am I missing?

Try deleting the event daemon data folder, which is configured in the daemon. Specifically
There are also logs in the same directory, which you could check for more information.

Dude, Python 2.7 has been deprecated for about 10 years, it’s time to switch :slight_smile:
I think there are fixes in the event daemon github to make it work.

I did all that, even started entirely new folders (with respectively updated configs).

Dude, Python 2.7 has been deprecated for about 10 years

Yeah, I know that but due to the VFX industry being behind by about 10 years this is still fairly recent switch in our world. The event daemon framework itself wasn’t updated to Python 3 for quite some time and since everything was working just fine until about a week ago and went by the old “never change a running system” philosophy (especially seeing I have to look after IT as well as production).

I will try running everything via Pythyon 3 though, maybe a recent windows update decided to no longer accept Python 2.7 as a service command.


You should really debug the service startup, and get more logs from there. Not sure how. Does the command line start of the service spit out just this single error message?

Command line start only says it is starting the service and that’s it. I have to look into the windows event logs to see the above errors.

No idea how to get any more info.

Did you try
Start-Service shotgunEventDaemon
from powershell?
But really if the program gets to the point of writing logs, you should look in those. The directory is configured in the event daemon configuration.

PS C:\WINDOWS\system32> Start-Service ShotgunEventDaemon
Start-Service : Failed to start service 'Shotgun Event Handler (ShotgunEventDaemon)'.
At line:1 char:1
+ Start-Service ShotgunEventDaemon
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand

But really if the program gets to the point of writing logs, you should look in those. The directory is configured in the event daemon configuration.

It doesn’t get that far, windows fails to start the service, so the SG logs won’t help.And as mentioned before the windows logs just say:

The Shotgun Event Handler service terminated with the following service-specific error:

Incorrect function.

Hmm ok, I see. Here’s an idea: is the correct function being called by the service? What command does the service call?

No idea, I guess whatever is set up by install

I can’t find any info in the service properties or the logs.
My wild guess is that it is referring to PythonService.exe and possibly the last windows update decided that Python 2.7 is no longer acceptable to run as a service. This is the only thing I can think of but I have not yet had the time to try Python 3 to verify this.

In the windows service you can see “path to executable”. I don’t know if this also includes any arguments.
I have not tested install (we have our own system). Have you updated the event daemon recently?

I did after the trouble started, so I am using the latest version.
I am about to free up from a marathon show, so will probably raze the lot and get Python 3 on the job. Then report back

So what does “path to executable” say, I’m curious.


So I installed Python 3.7 with pywin32 then tried to install the service with that as per the GitHub docs. Now I get this:

PS C:\WINDOWS\system32> D:\Python37_7\python.exe \\\ohufx\pipeline\tools\python\shotgun_events\src\ install
Installing service ShotgunEventDaemon

**** WARNING ****
The executable at "D:\Python37_7\lib\site-packages\win32\PythonService.exe" is being used as a service.

This executable doesn't have pythonXX.dll and/or pywintypesXX.dll in the same
directory, and they can't be found in the System directory. This is likely to
fail when used in the context of a service.

The exact environment needed will depend on which user runs the service and
where Python is installed. If the service fails to run, this will be why.

NOTE: You should consider copying this executable to the directory where these
DLLs live - "D:\Python37_7\lib\site-packages\win32" might be a good place.

I tried copying the dlls into the same directory as the exe but got the same error.
The location where PythonService.exe is run from is controlled by this command ai assume: install

Where to from here (I’m no windows expert)?

I just copied the dlls as per the above message and the service installed successfully using Python 3. However, when I try to start it I am still getting an error:

The event log now says this:

The Shotgun Event Handler service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.

All utterly unhelpful.

So frustrating after having this working for years…


Your PATH variable is wrong, it must include the path to pythonXX.dll (I guess e.g. c:\Python38-32).

Copying dlls is never a good idea (when other solutions are possible).

Yeah, I never do this either but wanted to test to see what the actual problem is.
By now I am getting teh same error as with Python 2 (“incorrectr function”).
I logged an issue in the github repo but no traction.
There must be a way to debug this in a constructive manner…

FWIW, I’m tried to do the same using a 2.7 install and got something similar - I’m not sure how much free air I’ve got, but I guess sometime this weekend I might have to learn about windows services. How hard could it be?

Haha, exactly. The annoying thing is that I set this up two years ago withut trouble and it had been running ever since.
I set it up for other companies in the past as well without trouble.
But now I am stuck

@mmoshev I have deleted the copied dlls now and updated my PATH to include those paths:


Rebooted just to make sure, removed and tried to reinstall the servie, but am getting this error again:

Did you check that pythonXX.dll and pywintypesXX.dll are in these directories?

Did you see that others have asked about the “incorrect function” error?

This also could be an environment problem.