0

If you are using some modules in a function passed to Server.submit [docs], you need to specify these in the modules argument. See below:

import os

def get_os_name():
  return os.name

jobserver.submit(get_os_name,modules=('os',))

But, I would like to do something like this:

from os import name

def get_os_name():
  return name

# Obviously won't work
jobserver.submit(get_os_name,modules=('os',))

How do I get the second code chunk to work? I tried replace 'os' with 'os.name' and stuff like that, but no luck.

Phil Miller
  • 36,389
  • 13
  • 67
  • 90
Marcus Johansson
  • 2,626
  • 2
  • 24
  • 44

1 Answers1

0

Try this:

exec("jobserver.submit(get_os_name,modules=('os',))")
Reza Ebrahimi
  • 3,623
  • 2
  • 27
  • 41