title: Python Socket Call server.py and client.py in main.py
body: <p>My question is that how to call server and client sequentially in main method ? </p>
  
  <p>Problem is that python debugger waiting and be suck in line that calling the server(blocking the calling client line). </p>
  
  <p>I tried threading but not work . Thanks for your attention.</p>
  
  <p>IMPORTANT: Below codes using Python2</p>
  
  <p>Main python file:</p>
  
  <pre><code>import xClient
  import xServer
  import threading
  
  tempServer=xServer
  
  tempClient=xClient
  
  thrMain = threading.Thread(target=tempServer.innerClient.Main())
  thrMain.start()
  thrMain.join()
  
  tempClient.innerClient.Main()
  </code></pre>
  
  <p>xClient.py : # STANDARD Client code and works correctly</p>
  
  <pre><code>import socket
  import time
  
  class innerClient:
      def Main():
          time.sleep(2)
          host = '127.0.0.1'
          port = 12345
          s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          s.connect((host, port))
          message = "test message"
          while True:
              s.send(message.encode('ascii'))
              data = s.recv(1024)
              print('Received from the server :', str(data.decode('ascii')))
  
  
              ans = raw_input('Continue(y/n) :')
              if ans == 'y':
                  continue
              else:
                  break
          s.close()
  </code></pre>
  
  <p>xServer.py : # STANDARD Server code and works correctly</p>
  
  <pre><code>import socket
  import threading
  class innerServer:
      print_lock = threading.Lock()
  
      # thread fuction
      def threaded(c):
          while True:
              data = c.recv(1024)
              if not data:
                  print('See you later')
                  print_lock.release()
                  break
              data = data[::-1]
              c.send(data)
          c.close()
  
      def Main():
          host = ""
          port = 12345
          s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          s.bind((host, port))
          print("socket binded to post", port)
          s.listen(5)
          print("socket is listening")
          while True:
              c, addr = s.accept()
              print_lock.acquire()
              print('Connected to :', addr[0], ':', addr[1])
  
              thr = threading.Thread(target=threaded, args=(c,))
              thr.start()
              thr.join()
          s.close()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8tvR4.png" rel="nofollow noreferrer">TCP Socket Diagram</a></p>