Re: PubSub and working thread

Robin Dunn <[email protected]> Wed, 3 Apr 2019 15:18:25 -0700 (PDT)
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
------=_Part_1169_538252573.1554329905531
Content-Type: multipart/alternative; 
	boundary="----=_Part_1170_771841398.1554329905531"

------=_Part_1170_771841398.1554329905531
Content-Type: text/plain; charset="UTF-8"

On Wednesday, April 3, 2019 at 1:28:01 PM UTC-7, Nicolas Pinault wrote:
>
> Hi, 
>
> I have an application where I need to communicate between a working 
> thread and wx frames. 
> Threads can't directly call UI API so I usually do this with wx events. 
> The working thread sends messages to a frames using wx.Event. 
> It works  but this not as simple as with PubSub. 
> My concern is about the thread safety of PubSub. Is it safe to publish 
> from a working thread and subscribe from wx frames ? 
>

PubSub doesn't do anything with, nor is aware of threads. This means that 
the subscriber will be called in whatever thread was active when the 
message was sent. It's not difficult to work around however, as the 
subscribed function could simply use wx.CallAfter to schedule a call to 
some other function to do the real work.

--
Robin

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

------=_Part_1170_771841398.1554329905531
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, April 3, 2019 at 1:28:01 PM UTC-7, Nicolas P=
inault wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Hi,
<br>
<br>I have an application where I need to communicate between a working=20
<br>thread and wx frames.
<br>Threads can&#39;t directly call UI API so I usually do this with wx eve=
nts.=20
<br>The working thread sends messages to a frames using wx.Event.
<br>It works=C2=A0 but this not as simple as with PubSub.
<br>My concern is about the thread safety of PubSub. Is it safe to publish=
=20
<br>from a working thread and subscribe from wx frames ?
<br></blockquote><div><br></div><div>PubSub doesn&#39;t do anything with, n=
or is aware of threads. This means that the subscriber will be called in wh=
atever thread was active when the message was sent. It&#39;s not difficult =
to work around however, as the subscribed function could simply use wx.Call=
After to schedule a call to some other function to do the real work.</div><=
div><br></div><div>--</div><div>Robin</div><div><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">wxPyth=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

------=_Part_1170_771841398.1554329905531--

------=_Part_1169_538252573.1554329905531--