omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. HugoSviercovich

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    HugoSviercovich

    @HugoSviercovich

    0
    Reputation
    462
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    HugoSviercovich Unfollow Follow

    Latest posts made by HugoSviercovich

    • raw_input blocks a separate thread in Pythonista

      Hi, running the code below in Pythonista is not working as expected. Looks like the worker thread is being "blocked" by raw_input whereas in other platforms (Raspberry Pi, Windows - both v.2.7.3) same code allows it to run in the background normally.

      Can anybody reproduce this and help me understand if this is normal behaviour? Actually this code is just a simplification of what i'm trying to achieve with more complex code. I'm thinking this could probably be a particular iOS limitation.

      Thanks for your kind assistance.

      import threading
      import time
      
      class Worker():
      	def PrintSomething(self):
      		while True:
      			print "something"
      			time.sleep(1)
      					
      if __name__=="__main__":
      	worker=Worker()
      	wthread=threading.Thread(target=worker.PrintSomething)
      	wthread.start()
      	while True:
      		input=raw_input("Your input?: ") #waits for user input and currently blocks 'worker' thread in Pythonista
      		time.sleep(1)
      

      Expected result would be something like:

      Your input? : something
      something
      something
      something
      something
      something
      something
      Your input? : something
      something
      ...
      

      But it throws just this:

      something
      Your input?:
      
      posted in Pythonista
      HugoSviercovich
      HugoSviercovich