title: Socket concurrency in Python
body: <p>i'm working with this library: <a href="https://github.com/Simonefardella/escposprinter" rel="nofollow">ESCPOS Printer for Python</a> using the Ethernet class in order to communicate with printer: <a href="https://github.com/Simonefardella/escposprinter/blob/master/escposprinter/printer.py" rel="nofollow">CLASS ESCPOS ETHERNET</a></p>
  
  <p>I'm trying to execute a lot of calls using simple threads, like above:</p>
  
  <pre><code>from time import sleep
  import requests
  import threading
  import datetime
  from escposprinter import *
  from escposprinter.escpos import EscposIO, Escpos
  
  
  NumeroPartenza = 0
  NumeroFine = 9
  NumeroStampePerStampante = 1  
  
  
  printerPort = 9100
  dictionaryStampanti = {'printer1' : '192.168.0.196','printer2' : '192.168.0.197',  'printer3' : '192.168.0.198'}
  
  
  def printSimple(threadName, stampanteIp):
      with EscposIO(printer.Network(stampanteIp, printerPort)) as p:
          for iteration in range(NumeroStampePerStampante):
              p.set(font='a', codepage='cp1251', size='normal', align='center', bold=True)
              p.writelines('')
              p.writelines('')
              p.writelines('')
              p.writelines("{0}: {1}".format( threadName, datetime.datetime.now().strftime("%H:%M:%S.%f")))
              p.writelines('')
              p.writelines('')
              p.writelines('')
  
  
  
  #Testa stampante semplice
  for Ordine in range(NumeroPartenza, NumeroFine):
      stringToPrint = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
      threading.Thread(target=printSimple, args=("Thread1: " + stringToPrint, dictionaryStampanti.get('printer1')), ).start()
  
      threading.Thread(target=printSimple, args=("Thread2: " + stringToPrint, dictionaryStampanti.get('printer1')), ).start()
  
      threading.Thread(target=printSimple, args=("Thread3: " + stringToPrint, dictionaryStampanti.get('printer1')), ).start()
  </code></pre>
  
  <p>But frequently it fails, giving me the error: Err 60 Connection timed out, i mean, why using threads with concurrency calls to the printer i'm encountering this problem?</p>
  
  <p>Can anyone help me to solve this issue?</p>
  
  <p>Thanks</p>