Eel icon indicating copy to clipboard operation
Eel copied to clipboard

implementing multithreading

Open alphapats opened this issue 4 years ago • 3 comments

problem I have designed an app using eel. Main webpage has option for user to choose action needed. Once he clicks his option, it opens other webpage where he submits his query. This executes python code which takes 10-15 minutes to execute and get required data. I want this call to be non blocking so that user can go back and do other tasks in the app. I tried using eel.spawn, new thread is being created but I still can't do anything till it completes execution. I want thread to execute in background so that user should be able to start new thread or do other tasks.

Code snippet(s)

import eel
def my_thread1(query1):
	print("entered eel thread")
	eel.spawn(get_data(query1))  // This process need 10-15 minutes. It executes when user submits first type of query on GUI
        eel.sleep(1.0)    

def my_thread2(query2):
	print("entered eel thread")
	eel.spawn(get_data(query2))  // This process also need 10-15 minutes. It executes when user submits second type of query on GUI

def my_thread3():
            eel.spawn(browse_results())  // This process executes when user just want to see previous results

eel.init('web')
eel.start('index.html', size=(2000,1600),app_mode=None, block=False)
while True:
    print("I'm a main loop")
    eel.sleep(1.0)    


**Desktop (please complete the following information):**
 - OS: [Ubuntu]
 - Browser [Chrome]
 - Version [Chromium]

alphapats avatar Feb 15 '21 15:02 alphapats

Any Updates???

luciferamji avatar Sep 22 '21 06:09 luciferamji

i used python threading module within my program to implement multi-threading. User submits the request and function within eel spawns a thread to execute desired function and return to main eel program

alphapats avatar Sep 26 '21 05:09 alphapats

It looks like you may not be using eel.spawn correctly. You're passing get_data(query1), which executes that function immediately and passes the result to eel.spawn. Have you tried it as eel.spawn(get_data, query1)? All it does is call gevent's spawn, which is documented here: https://www.gevent.org/api/gevent.html#gevent.spawn

samuelhwilliams avatar Sep 27 '21 08:09 samuelhwilliams