TwistedStatsDClient.write isn't thread-safe

Bug #838262 reported by Thomas Herve
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
txStatsD
Fix Released
High
Ian Wilkinson

Bug Description

write is meant to be called in threads sometimes, my Metric.send, for example in WSGi application. It should use reactor.callFromThread to be threadsafe/

Thomas Herve (therve)
Changed in txstatsd:
importance: Undecided → High
Revision history for this message
Ian Wilkinson (theiw) wrote : Re: [Bug 838262] [NEW] TwistedStatsDClient.write isn't thread-safe

 If you use UdpStatsDClient as the connection:

connection = UdpStatsDClient(host, port)
metrics = Metrics(connection)

then sending will be thread-safe.

ian

On Wednesday, 31 August 2011 at 18:40, Thomas Herve wrote:

> Public bug reported:
>
> write is meant to be called in threads sometimes, my Metric.send, for
> example in WSGi application. It should use reactor.callFromThread to be
> threadsafe/
>
> ** Affects: txstatsd
> Importance: High
> Status: New
>
> ** Changed in: txstatsd
> Importance: Undecided => High
>
> --
> You received this bug notification because you are a member of txStatsD
> Developers, which is the registrant for txStatsD.
> https://bugs.launchpad.net/bugs/838262
>
> Title:
> TwistedStatsDClient.write isn't thread-safe
>
> Status in txStatsD: A Twisted implementation of StatsD:
> New
>
> Bug description:
> write is meant to be called in threads sometimes, my Metric.send, for
> example in WSGi application. It should use reactor.callFromThread to
> be threadsafe/
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/txstatsd/+bug/838262/+subscriptions

Revision history for this message
Thomas Herve (therve) wrote :

Agreed. But we use it in a twisted application, so it's better to benefit from the twisted loop, as it won't block. The fix is fairly trivial, too.

Revision history for this message
Ian Wilkinson (theiw) wrote : Re: [Bug 838262] Re: TwistedStatsDClient.write isn't thread-safe

 The fix is trivial as you suggest it. However there is nothing in
Metrics that dictates the use of Twisted. We have a separation of
client and server, where the server is a Twisted implementation, and
the client is not necessarily running within a Twisted application.

If the fix could respect both Twisted and non-Twisted use of Metrics
I think that would be preferable.

On Friday, 2 September 2011 at 13:32, Thomas Herve wrote:

> Agreed. But we use it in a twisted application, so it's better to
> benefit from the twisted loop, as it won't block. The fix is fairly
> trivial, too.
>
> --
> You received this bug notification because you are a member of txStatsD
> Developers, which is the registrant for txStatsD.
> https://bugs.launchpad.net/bugs/838262
>
> Title:
> TwistedStatsDClient.write isn't thread-safe
>
> Status in txStatsD: A Twisted implementation of StatsD:
> New
>
> Bug description:
> write is meant to be called in threads sometimes, my Metric.send, for
> example in WSGi application. It should use reactor.callFromThread to
> be threadsafe/
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/txstatsd/+bug/838262/+subscriptions

Revision history for this message
Ian Wilkinson (theiw) wrote :

Please ignore the previous comment.

Yes, it seems reasonable to change TwistedStatsDClient.write as you suggest.

On Friday, 2 September 2011 at 13:59, Ian Wilkinson wrote:

> The fix is trivial as you suggest it. However there is nothing in
> Metrics that dictates the use of Twisted. We have a separation of
> client and server, where the server is a Twisted implementation, and
> the client is not necessarily running within a Twisted application.
>
> If the fix could respect both Twisted and non-Twisted use of Metrics
> I think that would be preferable.
>
>
> On Friday, 2 September 2011 at 13:32, Thomas Herve wrote:
>
> > Agreed. But we use it in a twisted application, so it's better to
> > benefit from the twisted loop, as it won't block. The fix is fairly
> > trivial, too.
> >
> > --
> > You received this bug notification because you are a member of txStatsD
> > Developers, which is the registrant for txStatsD.
> > https://bugs.launchpad.net/bugs/838262
> >
> > Title:
> > TwistedStatsDClient.write isn't thread-safe
> >
> > Status in txStatsD: A Twisted implementation of StatsD:
> > New
> >
> > Bug description:
> > write is meant to be called in threads sometimes, my Metric.send, for
> > example in WSGi application. It should use reactor.callFromThread to
> > be threadsafe/
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/txstatsd/+bug/838262/+subscriptions

Ian Wilkinson (theiw)
Changed in txstatsd:
assignee: nobody → Ian Wilkinson (theiw)
status: New → In Progress
Revision history for this message
Ian Wilkinson (theiw) wrote :

The fix features in the revno 31 release.

Changed in txstatsd:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.