message.data becoms None in spawned greenlets
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- backend, networking
Direzione di ricerca
Start at ws4py.websocket.WebSocket and the received_message entry point, then trace the message lifecycle when gevent.spawn runs the handler. Reproduce the reported behavior if possible and determine what should preserve message.data; done means spawned handlers receive the original data without requiring deepcopy, with a regression test if the project supports one.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi there,
I don't have a self-contained test case but I can easily reproduce the following nevertheless in my project.
In a subclass of ws4py.websocket.WebSocket that is running in a gevent-based server I implemented the received_message method.
This works fine as long as it looks similar to the below:
def received_message(self, message):
_self._on_received_message(message.data)
However, the moment I spawn the handler function into its own greenlet as below ..
from gevent import spawn
def received_message(self, message):
spawn(_self._on_received_message, message.data)
.. message.data becomes None somewhere between spawn and the moment _self._on_received_message gets called but at any rate _self._on_received_message receives None, the original data is lost by the time that method is called in its own greenlet.
The workaround is to deepcopy it before spawning the greenlet
from copy import deepcopy
from gevent import spawn
def received_message(self, message):
spawn(_self._on_received_message, deepcopy(message.data))
- Lingua principale
- Python
- Stelle
- 1.1k
- Fork
- 286
- Merge medio
- 1g 19h
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 Lawouach/WebSocket-for-Python
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Lawouach/WebSocket-for-Python#300 ·
-
This project is not well maintained so be very very very patient!Forse di nuovo libera @Lawouach l’ha presa 660 giorni fa e non c’è nessuna pull request aperta. Apertaquestion
Lawouach/WebSocket-for-Python#297 · 2 commenti · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Make the codes python 3 compatibleForse di nuovo libera @auvipy l’ha presa 1066 giorni fa e non c’è nessuna pull request aperta. Aperta
Lawouach/WebSocket-for-Python#280 · 1 commento · 1 assegnatario ·
-
Setup new CIForse di nuovo libera @auvipy l’ha presa 1238 giorni fa e non c’è nessuna pull request aperta. Aperta
Lawouach/WebSocket-for-Python#275 · 1 assegnatario ·
Tutte le issue di Lawouach/WebSocket-for-Python
Issue simili
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hatchet-dev/hatchet#5179 ·
I maintainer di solito rispondono entro 1 giorno
-
python-version
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
bug javascript P2-medium python release:v3.1
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
adrirubio/claude-deck#546 ·
I maintainer di solito rispondono entro 1 giorno