Re: When is it safe to call PyStackless_Schedule
Robert Babiak <[email protected]> Tue, 9 Sep 2014 21:57:30 -0600
| Newsgroups | gmane.comp.python.stackless |
|---|---|
| Message-ID | <CAEmPv6EMHfH0sJLLu=ZmAvz_7jz4OSg7-4b0_34aH2bU3Er+7w@mail.gmail.com> |
--===============8120548950944232123==
Content-Type: multipart/alternative; boundary=001a11c23948109fb70502ae0da1
--001a11c23948109fb70502ae0da1
Content-Type: text/plain; charset=UTF-8
I took the Receive out and replaced it with a simple call to
PyStackless_Schedule.
static int EventHook(void)
{
PyStackless_Schedule(Py_None, 0);
return 0;
}
...
Py_SetProgramName(argv[0]);
Py_InitializeEx(0);
if (!Py_IsInitialized())
{
std::cerr << "Python initialization failed" << std::endl;
return;
}
PySys_SetArgv(argc, argv);
PyOS_InputHook = EventHook;
...
// stacklessMain returns when program is shutdown.
PyStackless_CallMethod_Main(oMainModule.ptr(), "stacklessMain", 0);
...
This is the lldb stacktrace
frame #0: 0x0000000100ea30a3 Python`PyStackless_Schedule + 51
frame #1: 0x0000000100155fd9 main`EventHook() + 25 at
pythonInterperter.cpp:472
frame #2: 0x0000000103dd5e25 readline.so`call_readline + 293
frame #3: 0x0000000100dfa3c3 Python`PyOS_Readline + 179
frame #4: 0x0000000100e92882 Python`builtin_raw_input + 434
frame #5: 0x0000000100e95d88 Python`PyEval_EvalFrame_value + 3832
frame #6: 0x0000000100e94d38 Python`PyEval_EvalFrameEx_slp + 376
frame #7: 0x0000000100e9744c Python`PyEval_EvalFrame_value + 9660
frame #8: 0x0000000100e94d38 Python`PyEval_EvalFrameEx_slp + 376
frame #9: 0x0000000100e9744c Python`PyEval_EvalFrame_value + 9660
frame #10: 0x0000000100e94d38 Python`PyEval_EvalFrameEx_slp + 376
frame #11: 0x0000000100e9e9e1 Python`slp_frame_dispatch_top + 49
frame #12: 0x0000000100ea2772 Python`slp_run_tasklet + 226
frame #13: 0x0000000100e9e0fc Python`slp_eval_frame + 348
frame #14: 0x0000000100e9e083 Python`slp_eval_frame + 227
frame #15: 0x0000000100e9e083 Python`slp_eval_frame + 227
.....
frame #719: 0x0000000100e9e083 Python`slp_eval_frame + 227
frame #720: 0x0000000100e9e083 Python`slp_eval_frame + 227
frame #721: 0x0000000100ea3801 Python`PyStackless_CallMethod_Main + 433
frame #722: 0x00000001001588e3
main`PythonThread::operator(this=0x0000000101506940)() + 1187 at
pythonInterperter.cpp:555
frame #723: 0x000000010015761c
main`boost::detail::thread_data<PythonThread>::run(this=0x0000000101506740)
+ 28 at thread.hpp:117
frame #724: 0x00000001010ff24a libboost_thread-mt.dylib`thread_proxy +
186
frame #725: 0x00007fff863fb899 libsystem_pthread.dylib`_pthread_body +
138
frame #726: 0x00007fff863fb72a libsystem_pthread.dylib`_pthread_start +
137
On Tue, Sep 9, 2014 at 9:17 PM, Richard Tew <[email protected]> wrote:
> If you have a crash when you call receive, then you likely have larger
> problems than when the right time to call schedule is.
>
> I don't think it's possible to divine what is going wrong, and expect
> you need to provide a reproduction case.
>
> Cheers
>
> On 9/10/14, Robert Babiak <[email protected]> wrote:
> > Dear wise stackless list, I need some of your wisdom.
> >
> > I am trying to make raw_input play nice with the stackless scheduler and
> > not block with my embedded stackless.
> >
> > I set the PyOS_InputHook to get what amounts to an idle event but when I
> > call PyStackless_Schedule(PY_None, 0) it crashes (no stackless
> symbols...)
> >
> > Is there something I need to check to know if it is safe to call the
> > scheduler from C?
> >
> > In general when is it safe to call PyStackless_Schedule?
> >
> > I tried to call my BeNice to block and get woken up later, but this also
> > crashes when trying to receive on my BeNice channel.
> >
> > - Thanks Rob.
> > --
> > Life: Bah, I will worry about it when it is over.
> >
>
> _______________________________________________
> Stackless mailing list
> [email protected]
> http://www.stackless.com/mailman/listinfo/stackless
>
--
Life: Bah, I will worry about it when it is over.
--001a11c23948109fb70502ae0da1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I took the Receive out and replaced it with a simple call =
to PyStackless_Schedule.=C2=A0<div><br></div><div><div>static int EventHook=
(void)</div><div>{</div><div>=C2=A0 =C2=A0 PyStackless_Schedule(Py_None, 0)=
;</div><div>=C2=A0 =C2=A0 return 0;</div><div>}</div></div><div>...</div><d=
iv><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Py_SetProgramName(argv[0]);</div><div>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Py_InitializeEx(0);</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 if (!Py_IsInitialized())</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 {=
</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 std::cerr << &qu=
ot;Python initialization failed" << std::endl;</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 }</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 PySys_SetArgv(argc, argv);</=
div></div><div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 PyOS_InputHook =3D EventHoo=
k;</div></div><div>...</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // stacklessMa=
in returns when program is shutdown.</div><div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 PyStackless_CallMethod_Main(oMainModule.ptr(), "stacklessMain&q=
uot;, 0);</div></div><div>...</div><div><br></div><div>This is the lldb sta=
cktrace</div><div>
<p class=3D"">frame #0: 0x0000000100ea30a3 Python`PyStackless_Schedule + 51=
</p><p class=3D"">=C2=A0frame #1: 0x0000000100155fd9 main`EventHook() + 25 =
at pythonInterperter.cpp:472</p>
<p class=3D"">=C2=A0 =C2=A0 frame #2: 0x0000000103dd5e25 readline.so`call_r=
eadline + 293</p>
<p class=3D"">=C2=A0 =C2=A0 frame #3: 0x0000000100dfa3c3 Python`PyOS_Readli=
ne + 179</p>
<p class=3D"">=C2=A0 =C2=A0 frame #4: 0x0000000100e92882 Python`builtin_raw=
_input + 434</p>
<p class=3D"">=C2=A0 =C2=A0 frame #5: 0x0000000100e95d88 Python`PyEval_Eval=
Frame_value + 3832</p>
<p class=3D"">=C2=A0 =C2=A0 frame #6: 0x0000000100e94d38 Python`PyEval_Eval=
FrameEx_slp + 376</p>
<p class=3D"">=C2=A0 =C2=A0 frame #7: 0x0000000100e9744c Python`PyEval_Eval=
Frame_value + 9660</p>
<p class=3D"">=C2=A0 =C2=A0 frame #8: 0x0000000100e94d38 Python`PyEval_Eval=
FrameEx_slp + 376</p>
<p class=3D"">=C2=A0 =C2=A0 frame #9: 0x0000000100e9744c Python`PyEval_Eval=
Frame_value + 9660</p>
<p class=3D"">=C2=A0 =C2=A0 frame #10: 0x0000000100e94d38 Python`PyEval_Eva=
lFrameEx_slp + 376</p>
<p class=3D"">=C2=A0 =C2=A0 frame #11: 0x0000000100e9e9e1 Python`slp_frame_=
dispatch_top + 49</p>
<p class=3D"">=C2=A0 =C2=A0 frame #12: 0x0000000100ea2772 Python`slp_run_ta=
sklet + 226</p>
<p class=3D"">=C2=A0 =C2=A0 frame #13: 0x0000000100e9e0fc Python`slp_eval_f=
rame + 348</p>
<p class=3D"">=C2=A0 =C2=A0 frame #14: 0x0000000100e9e083 Python`slp_eval_f=
rame + 227</p>
<p class=3D"">=C2=A0 =C2=A0 frame #15: 0x0000000100e9e083 Python`slp_eval_f=
rame + 227</p><p class=3D"">.....</p>
<p class=3D"">=C2=A0 =C2=A0 frame #719: 0x0000000100e9e083 Python`slp_eval_=
frame + 227</p><p class=3D"">=C2=A0 =C2=A0 frame #720: 0x0000000100e9e083 P=
ython`slp_eval_frame + 227</p><p class=3D"">=C2=A0 =C2=A0 frame #721: 0x000=
0000100ea3801 Python`PyStackless_CallMethod_Main + 433</p><p class=3D"">=C2=
=A0 =C2=A0 frame #722: 0x00000001001588e3 main`PythonThread::operator(this=
=3D0x0000000101506940)() + 1187 at pythonInterperter.cpp:555</p><p class=3D=
"">=C2=A0 =C2=A0 frame #723: 0x000000010015761c main`boost::detail::thread_=
data<PythonThread>::run(this=3D0x0000000101506740) + 28 at thread.hpp=
:117</p><p class=3D"">=C2=A0 =C2=A0 frame #724: 0x00000001010ff24a libboost=
_thread-mt.dylib`thread_proxy + 186</p><p class=3D"">=C2=A0 =C2=A0 frame #7=
25: 0x00007fff863fb899 libsystem_pthread.dylib`_pthread_body + 138</p><p cl=
ass=3D"">
</p><p class=3D"">=C2=A0 =C2=A0=C2=A0frame #726: 0x00007fff863fb72a libsyst=
em_pthread.dylib`_pthread_start + 137</p></div></div><div class=3D"gmail_ex=
tra"><br><div class=3D"gmail_quote">On Tue, Sep 9, 2014 at 9:17 PM, Richard=
Tew <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" targe=
t=3D"_blank">[email protected]</a>></span> wrote:<br><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex">If you have a crash when you call receive, then you likel=
y have larger<br>
problems than when the right time to call schedule is.<br>
<br>
I don't think it's possible to divine what is going wrong, and expe=
ct<br>
you need to provide a reproduction case.<br>
<br>
Cheers<br>
<div><div class=3D"h5"><br>
On 9/10/14, Robert Babiak <<a href=3D"mailto:[email protected]">rbabiak@=
gmail.com</a>> wrote:<br>
> Dear wise stackless list, I need some of your wisdom.<br>
><br>
> I am trying to make raw_input play nice with the stackless scheduler a=
nd<br>
> not block with my embedded stackless.<br>
><br>
> I set the PyOS_InputHook to get what amounts to an idle event but when=
I<br>
> call PyStackless_Schedule(PY_None, 0) it crashes (no stackless symbols=
...)<br>
><br>
> Is there something I need to check to know if it is safe to call the<b=
r>
> scheduler from C?<br>
><br>
> In general when is it safe to call=C2=A0 PyStackless_Schedule?<br>
><br>
> I tried to call my BeNice to block and get woken up later, but this al=
so<br>
> crashes when trying to receive on my BeNice channel.<br>
><br>
> - Thanks Rob.<br>
> --<br>
> Life: Bah, I will worry about it when it is over.<br>
><br>
<br>
</div></div>_______________________________________________<br>
Stackless mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]</a><br>
<a href=3D"http://www.stackless.com/mailman/listinfo/stackless" target=3D"_=
blank">http://www.stackless.com/mailman/listinfo/stackless</a><br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Life: Bah, I=
will worry about it when it is over.
</div>
--001a11c23948109fb70502ae0da1--
--===============8120548950944232123==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless
--===============8120548950944232123==--