How can you pass additional args to a worker function?

How to pass the additional args and kwargs in execute_this_fn below is my code

worker = Worker(lambda :self.execute_this_fn(arg1, arg2, kwarg1)

I am getting

TypeError: <lambda>() got an unexpected keyword argument 'progress_callback'

Have u got a chance to figured this out? I have the same problem.

Because I have an error when I’m passing parameters to function like this:

worker = Worker(self.execute_this_fn, param1, param2)

Error is:

TypeError: execute_this_fn() got multiple values for argument 'progress_callback'

Hi, i have experimented quite a lot with the classes and QThreadPool concepts in this tutorial. By far the best i could find on the topic!.

In your slot function, you must add a **kwargs whether you plan to emit the signal or not, because the progress_callback is added as a keyword argument automatically in the Worker __init__

Check it out:

class Worker(QRunnable):
...
def  **init** (self,
self.kwargs['progress_callback'] = self.signals.progress

Sorry coming late to this party but here’s what I found works (so far):

change execute_this_fn signature:

def exec_this_fn(self, progress_callback, start=0):
for n in range(start, 5):

Then in the oh_no function, change worker initiation to

worker = Worker(self.execute_this_fn, start=2)

In this trivial example, the “start” parameter lets me start the count from 2 rather than 0.

Hope this helps.

Thank you for your reply, Your answer was much helpful,
I am facing new problem please can you help me?
I have pyqtgraph window inside my QDialog, i am calling the QDialog from my mainwindow application (through Worker thread), some times the QDialog runs proprely, some times the whole GUI is crashes with out giving any error message.
If i wont run the QDialog from Worker thread the QDialog will freeze until the task in completed.

My final intention is to run the sub window (QDialog) in thread, with out being freeze.