Disclaimer, I am new to python.
I wanted to test Threads and especially daemons in Python, I wrote a simple application which calls an endpoint in a daemon every x - seconds. However when I pass a String
to the target function, the value is empty:
Creation of the daemon:
daemon = threading.Thread(target=thread_function, args=(url,), daemon=True)
daemon.start()
Target function:
def thread_function(url):
print("Thread operates with url: ", url)
while True:
data = call_endpoint(url)
followers = parser(data)
print("The selected account has {} followers!".format(followers))
time.sleep(5)
Expected result:
Thread operates with url: https://www.instagram.com/username/?__a=1
Actual result:
Thread operates with url:
This is weird, because when I pass the int value 1 to the target function output is:
Thread operates with url: 1
Note the string url is not empty, I even tried:
daemon = threading.Thread(target=thread_function, args=("Hello",), daemon=True)
Output:
Thread operates with url: