ShotgunEventDaemon can't run in background

We are implementing ShotgunEventDaemon for some systematic task.
It runs perfectly when run in Foreground but I’m unable to launch it in background using start argument.
Here’s the error I get:

[ws] user ~ >python3 /prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/ start
Traceback (most recent call last):
File “/prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/”, line 1418, in
File “/prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/”, line 1382, in main
File “/prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/”, line 1353, in start
super(LinuxDaemon, self).start(daemonize)
File “/prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/”, line 115, in start
File “/prod/studio/libs/python/3.6/linux/site-packages/shotgunEvents/src/”, line 74, in _daemonize
se = open(self._stderr, “a+”, 0)
ValueError: can’t have unbuffered text I/O

Any clue on what could cause this error? Thank!

Nothing different with Python3.7

1 Like

Odds are you need to be ‘root’ to run this as a daemon (presumably due to the system-level permissions required for a process to be properly registered as a daemon). I’ve never had any success running it as a non-root user.


Thank you for your reply.
Unfortunately, I’ve just tested it as root and I get the exact same error.

This looks like a bug, I’ll run it past the team. As far as I can see you can only pass 0 as a buffer parameter if you’re are using binary.

OK, thanks.

Should I start a support ticket then? or will you update this forum post?

Could you try opening the file in binary mode, a+b?


So I’ve changed line 74 of from:

    se = open(self._stderr, "a+", 0)


     se = open(self._stderr, "a+b", 0)

I didn’t get any error this time but the daemon is not running. There is a pid register in the log file but this pid is not running.

1 Like

Hi Philip, when could I expect a return from the team on this matter?

Hi, I’ve added an internal ticket for this, we’ll update this thread when it’s resolved.

1 Like

Hi @Kevin_Lmr I’m sorry it’s taken a while to look at this, when I change the code to become:

se = open(self._stderr, "a+b", 0)

It starts working for me, the event service starts and my events are triggered. I’m not sure what is happening in your situation at the moment.

I think

se = open(self._stderr, "a+")

would also work as well, though at present I’m unsure which fix is the right way to go.

Hi @philip.scadding,

I finally had some time to dig for this error.

Your solution did the trick but we also had a second error that was not caught by the daemon.
The second error was linked to the daemon not being able to write in /var/lock/subsys and not reporting a single notification about it. I suppose this is link to the answer of @nico.vandenbosch but by that time, I didn’t try both solution simultaneously.

I’ve posted a pull request with this.

Thank you all!

1 Like

Hi Kevin

Thanks for that, I’d created a PR as well for the Python 3 fix.
I can’t see your PR though?


Just to say we merged the fix into the master so it is effectively released, though we don’t actually tag this repository.
Thanks for reporting this!

1 Like