Handing asynchronus sock recv python
<p>Main.py:</p>

<pre><code>def thread(i):
    while True:
        try:
            lock.acquire()
            if shared_var == 0:
                Client.f1()
                shared_var +=1
            if shared_var == 2:
                Client.f2()
                time.sleep(DELAY)
                shared_var += 1
            if shared_var == 3:
                time.sleep(5)
                Client.f3()
                Client.f4()
                shared_var += 1
        finally:
            lock.release()

if __name__ == '__main__':
        thread1 = threading.Thread(target=thread, args=(0,))
        thread1.start() 
</code></pre>

<p>Client.py:</p>

<pre><code>def socket():
def f1():#send function
def f2():#recv function.
def f3():
def f4():
def f5():
</code></pre>

<p>I have <strong>non blocking socket</strong> at client side.
I have thread in main file which calls this functions
at client side. I have a function(lets say f2) which will be receiving some data through socket. I will be sending series of commands through socket and will be getting response in function f2.
Let say my function f3 is sync function which monitor the server notifies me if any state changes occurs in server.
<strong>Problem:</strong> 
Since am getting multiple response from server i want to catch specifically catch the state changes response form server. Is it possible?</p>

<p>Note : Am using a generic function for send and recv which means all functions sends the commands and recv the response via f1 and f2.</p>

<p>Ps am a newbie to python</p>