File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -23,30 +23,31 @@ cdef class _StreamWriteContext:
23
23
self .closed = 1
24
24
PyBuffer_Release(& self .py_buf) # void
25
25
self .req.data = NULL
26
- Py_DECREF(self )
27
26
IF not DEBUG:
28
27
self .stream = None
28
+ Py_DECREF(self )
29
29
30
30
@staticmethod
31
31
cdef _StreamWriteContext new(UVStream stream, object data):
32
32
cdef _StreamWriteContext ctx
33
33
ctx = _StreamWriteContext.__new__ (_StreamWriteContext)
34
+ ctx.stream = None
35
+ ctx.closed = 1
34
36
35
37
ctx.req.data = < void * > ctx
36
38
37
39
PyObject_GetBuffer(data, & ctx.py_buf, PyBUF_SIMPLE)
38
40
ctx.uv_buf = uv.uv_buf_init(< char * > ctx.py_buf.buf, ctx.py_buf.len)
39
41
ctx.stream = stream
40
42
41
- ctx.closed = 0
42
-
43
43
IF DEBUG:
44
44
stream._loop._debug_stream_write_ctx_total += 1
45
45
stream._loop._debug_stream_write_ctx_cnt += 1
46
46
47
47
# Do incref after everything else is done
48
48
# (PyObject_GetBuffer for instance may fail with exception)
49
49
Py_INCREF(ctx)
50
+ ctx.closed = 0
50
51
return ctx
51
52
52
53
IF DEBUG:
@@ -56,9 +57,9 @@ cdef class _StreamWriteContext:
56
57
' open _StreamWriteContext is being deallocated' )
57
58
58
59
IF DEBUG:
59
- self .stream._loop._debug_stream_write_ctx_cnt -= 1
60
-
61
- self .stream = None
60
+ if self .stream is not None :
61
+ self .stream._loop._debug_stream_write_ctx_cnt -= 1
62
+ self .stream = None
62
63
63
64
64
65
@cython.no_gc_clear
You can’t perform that action at this time.
0 commit comments