Socket with if-loops does not give a consistent result
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- desktop, networking
Direzione di ricerca
Inizia dal punto di ingresso show_markers e segui il ciclo intorno allo stato della casella di controllo, alle chiamate recv e ai percorsi di shutdown/close del socket. Riproduci la sequenza di tre attivazioni, quindi verifica che il ritorno allo stato selezionato riceva dati senza bloccarsi e che il ciclo di vita del socket rimanga valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The program is continuously receiving data from the sender side. And I have a checked/unchecked button when I make it checked it runs the if part...that's good. Now I make it unchecked then else part runs and prints Unchecked going to close socket, so that's also good.
The problem is when I am going to make it again checked (2nd time) to run if part again it just print Checked and my program hangs. Why is this happening? It should receive the data but it hangs. Please tell me the solution.
def show_markers(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostbyname('192.168.225.12')
s.connect((host, port))
scale=0
while True:
if self.iconAction.isChecked():
print ('Checked')
m = QgsVertexMarker(self.iface.mapCanvas())
data = s.recv(SIZE)
data1 = s.recv(SIZE)
c = data.decode()
d = data1.decode()
x = float(c)
y = float(d)
print("printing X :", x)
print("printing Y :", y)
rect = QgsRectangle(float(x)-scale, float(y)-scale, float(x)+scale, float(y)+scale)
me = self.iface.mapCanvas()
me.setExtent(rect)
me.refresh()
m.setCenter(QgsPointXY(x, y))
m.setColor(QColor(255, 0, 0))
m.setIconSize(7)
m.setIconType(QgsVertexMarker.ICON_X) # or ICON_CROSS, ICON_X
m.setPenWidth(3)
else:
print('Unchecked going to close socket')
s.shutdown(10)
s.close()
I am assuming it should work like:
- 1st time click on button ---> Checked & if part run [working]
- 2nd time click on button ---> Unchecked & else part run [working]
- 3rd time click on button ---> again it Checked [here it checked but my program hangs & not receiving the data from sender computer]
- Lingua principale
- Jupyter Notebook
- Stelle
- 5.2k
- Fork
- 5.3k
- Merge medio
- 4g 10h
- PR unite (30g)
- 10
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di realpython/materials
-
Ruff lints the whole repo Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
realpython/materials#729 ·
-
п Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
realpython/materials#763 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 55/100
realpython/materials#738 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 45/100
realpython/materials#737 ·
-
проект2 Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
realpython/materials#725 ·
Tutte le issue di realpython/materials
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
app bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
spotlight search visual bug Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AvengeMedia/DankMaterialShell#3537 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
CherryHQ/cherry-studio#20947 · 1 reazione ·