0

After a few hours of some digging trying to find a simple way of somthing that is so basic (can be done in 3 lines even in ASM) which is non blocking way of taking input, I had to ask somewhere. So if anyone has some eazy, simple, clean way of doing this I will be more than happy to hear :)

N.braha
  • 5
  • 5
  • 1
    Possible duplicate of [Python nonblocking console input](http://stackoverflow.com/questions/2408560/python-nonblocking-console-input) – Chris_Rands Nov 28 '16 at 17:01
  • Can you get more into detail about what exactly you are looking for? What have the hours of digging brought up? Why is what you found not applicable in this case? The question as it is now is too broad for this site. – ImportanceOfBeingErnest Nov 28 '16 at 17:02
  • 1
    user inputs are blocking operations. you need multithreaded or asynchronus code to handle multiple operations at once – Aaron Nov 28 '16 at 17:09
  • I have seen some solutions which are very cumbersome and not very understandable and simple and I would like to use somthing that I feel more comfrotable with to use in my code – N.braha Nov 28 '16 at 18:24

1 Answers1

0

To do this, you will need multiple threads. Here is a very basic example as to how you would set this up:

import thread

def get_input(txt):
    #do stuff here

thread.start_new(get_input, (type_message_here))

#do other stuff

This allows multiple things to run a the same time. Refer to:

https://docs.python.org/2/library/threading.html

Douglas
  • 1,304
  • 10
  • 26