DomandePython Threading eccezione non gestita
Qual è la ragione per l'eccezione?
Il client ha causato errori?
Se possibile, si prega di spiegare altri errori.
Sfondo
sto creando una presa Server Python GUI. Quando un client si connette al mio server, si aprirà la finestra della GUI (sto ancora lavorando a questo). Ma, quando un client si connette, ottengo un errore:
Unhandled exception in thread started by <function clientthread at 0x10246c230>
Poiché lo script reale è piuttosto lungo, ho provided a pastebin link.
ecco il codice thread. s
è il nome del mio oggetto socket
.
def clientthread(s):
#Sending message to connected client
#This only takes strings (words
s.send("Welcome to the server. Type something and hit enter\n")
#loop so that function does not terminate and the thread does not end
while True:
#Receiving from client
data = s.recv(1024)
if not data:
break
s.sendall(data)
print data
s.close()
traceback
Grazie per il suggerimento Morten. Ecco il traceback.
Socket Created
Socket Bind Complete
Socket now listening
Connected
Traceback (most recent call last):
File "/Users/BigKids/Desktop/Coding/Python 2/Sockets/Function/Server GUI Alpha Function.py", line 80, in clientthread
s.send("Welcome to the server. Type something and hit enter\n")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
Personalmente, credo che molti errori siano dovuti alla GUI.
Grazie!
Il tuo codice è iniziato per me bene. Cosa causa l'eccezione? – Igonato
@Igonato probabilmente una disconnessione client non credi? Solitamente viene sollevata un'eccezione IIRC –
@MortenJensen Ho aggiunto il mio client. Controllerò tra 15 minuti - Devo andare ed erg :) – xxmbabanexx