python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

AttributeError: module 'eel' has no attribute 'updateTaskLabel' #448

Closed taytanqbpass closed 3 years ago

taytanqbpass commented 3 years ago

Eel version v.0.14.0

Describe the bug Hi I get the error "AttributeError: module 'eel' has no attribute 'updateTaskLabel'" when using multiprocessing but not when threading.

code snippets

'This causes an error

@eel.expose
def runTask(task_obj):
    proc = multiprocessing.Process(target=runTask2, args=(task_obj,))
    proc.start()

but when I change it to:

def runTask(task_obj):
    thread1 = threading.Thread(target=runTask2, args=(task_obj,))
    thread1.start()

the error does not occur. Here's how my runTask2 looks like

def runTask2(task_obj):
  eel.updateTaskLabel(task_obj['tn'], 'Running')

Do note that updateTaskLabel is a javascript function whose code is below

eel.expose(updateTaskLabel);
function updateTaskLabel(task_no,status){
   $('#'+task_no+"_task_status").text(status);
}

Expected behavior eel.updateTaskLabel updates my eel front end task label

Desktop (please complete the following information):

taytanqbpass commented 3 years ago

@ChrisKnott @samuelhwilliams i would like to ask for your insight on this. Thanks.

ChrisKnott commented 3 years ago

You are probably going to run into problems using multiprocessing because I am not 100% sure how it launches the new processes. I think it goes through a different import and __init__ logic which means it isn't running Eel's code for discovering JS functions.

Basically, at the moment this isn't supported unfortunately.