Python Forum
Fork not supported for subinterpreters (help)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fork not supported for subinterpreters (help)
#1
Hi,

I have run out of people to ask this so now I'm here :)
I'm not familiar with python, all I ever worked with is C++.

I'm working on a addon for Kodi that will run rclone in the background for Android devices. Since on Windows and linux you can easily mount remotes with rclone in the background, android which is more restrictive would benefit from rclone running from within Kodi.

This used to work with Kodi 18, that uses Python 2.x, now that Kodi moved to version 19 and python 3.8 there are a few problems.

rclone needs to run in the background with a daemon.
The problem is that:

Quote:pid = os.fork()

results in
Quote:Fork not supported for subinterpreters

Since Python 3.8, as it can be seen here:
https://bugs.python.org/issue37951

The git I'm working is here:
https://github.com/fandangos/rclone-addon

The daemon code is simple, but I can't find any possible alternatives to pid = os.fork()

Quote: def daemonize(self):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
try:
pid = os.fork()
if pid > 0:
# exit first parent
sys.exit(0)
except OSError as e:
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
sys.exit(1)

# decouple from parent environment
os.chdir("/")
os.setsid()
os.umask(0)

# do second fork
try:
pid = os.fork()
if pid > 0:
# exit from second parent
sys.exit(0)
except OSError as e:
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
sys.exit(1)

# redirect standard file descriptors
sys.stdout.flush()
sys.stderr.flush()
si = file(self.stdin, 'r')
so = file(self.stdout, 'a+')
se = file(self.stderr, 'a+', 0)
os.dup2(si.fileno(), sys.stdin.fileno())

# write pidfile
atexit.register(self.delpid)
pid = str(os.getpid())
file(self.pidfile,'w+').write("%s\n" % pid)

Is this indeed a dead end for this project since Python 3.8 as I've been told?
Or is it possible to have a work around?

thank you in advance for whoever feels like taking the time to answer this thread.
Reply


Messages In This Thread
Fork not supported for subinterpreters (help) - by Fandangos - Dec-30-2020, 04:49 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020