I create a main function below with two argument function inside Thread.
if __name__ == "__main__":
# Define ports
ports_for_server_connection=[10003, 10004, 10005, 10006]
for port_number in ports_for_server_connection:
# Open multi thread sockets so that each will respond independently
t = Thread(target=openServer, args=(port_number, 1))
t.start()
However, I want to create that function with only one argument. When I tried to implement it with one argument(args=(port_number, 1)) I got the following error.
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
TypeError: openServer() argument after * must be an iterable, not int
How can I use thread with only one argument function?
Thanks,
openServerfunction definition