Skip to content

_thread.start_new_thread: How to use kwargs #17584

Answered by shariltumin
namgang asked this question in ESP32
Discussion options

You must be logged in to vote

I don't know the details of your script, but maybe this will help:

import _thread
import time

class test():
     def serverReport(self, id, what):
         print(f'ID: {id[0]}/{id[1]}, CMD: {what['cmd']} {what['val']}')

t = test()
# t.serverReport(('PRG', 123), {'cmd':'add', 'val':(3,4)})

# new_thread(func, (param))
_thread.start_new_thread(t.serverReport, (('PRG', 123), {'cmd':'add', 'val':(3,4)}))

time.sleep(5) # wait a bit
print('Done!')

This will give:

ID: PRG/123, CMD: add (3, 4)
Done!

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@namgang
Comment options

@namgang
Comment options

Answer selected by namgang
Comment options

You must be logged in to vote
1 reply
@namgang
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy