Socket with if-loops does not give a consistent result
維護者通常 5 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- desktop, networking
研究方向
從 show_markers 進入點開始,追蹤圍繞核取方塊狀態、recv 呼叫以及 socket shutdown/close 路徑的迴圈。重現三次切換的序列,然後驗證返回勾選狀態後能夠接收資料而不會掛起,並且 socket 生命週期仍然有效。
由索引模型根據 Issue 內容生成。
描述
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]
- 主要語言
- Jupyter Notebook
- 星號
- 5.2k
- 分支
- 5.3k
- 平均合併
- 5 天 4 小時
- 30 天內合併 PR
- 15
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
realpython/materials 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
realpython/materials#729 ·
維護者通常 5 天內回覆
-
п未關閉
難度 5/5 一週以上 新手友好度 1/100
realpython/materials#763 ·
維護者通常 5 天內回覆
-
難度 1/5 1 小時以內 新手友好度 55/100
realpython/materials#738 ·
維護者通常 5 天內回覆
-
難度 1/5 1 小時以內 新手友好度 45/100
realpython/materials#737 ·
維護者通常 5 天內回覆
-
проект2未關閉
難度 5/5 一週以上 新手友好度 15/100
realpython/materials#725 ·
維護者通常 5 天內回覆
查看 realpython/materials 的全部 Issue
相似的 Issue
-
Bug
難度 2/5 1-3 小時 新手友好度 76/100
pgadmin-org/pgadmin4#10503 ·
維護者通常 1 天內回覆
-
area:dictation bug P1
難度 2/5 1-3 小時 新手友好度 84/100
uttrflow/uttrflow-swift#5179 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
ProtonMail/WebClients#546 ·
-
omarchy display text size scales the Ghostty font two times可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
MaaAssistantArknights/MaaMacGui#152 · 2 則留言 ·
維護者通常 12 天內回覆