Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Steve D'Aprano
On Sat, 4 Nov 2017 05:12 am, Israel Brewster wrote: [...] >> People generally understand how to move data around, and the mistakes are >> usually pretty obvious when they happen. > > I think the existence of this thread indicates otherwise :-) This mistake > was far from obvious, and clearly I

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Rhodri James
On 03/11/17 18:12, Israel Brewster wrote: On Nov 3, 2017, at 7:11 AM, Rhodri James wrote: People generally understand how to move data around, and the mistakes are usually pretty obvious when they happen. I think the existence of this thread indicates otherwise :-)

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Israel Brewster
--- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 --- > On Nov 3, 2017, at 7:11 AM, Rhodri James wrote: > > On

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Gene Heskett
On Friday 03 November 2017 10:50:13 Chris Angelico wrote: > On Fri, Nov 3, 2017 at 10:26 PM, Rhodri James wrote: > > On 02/11/17 20:24, Chris Angelico wrote: > >> Thank you. I've had this argument with many people, smart people > >> (like Steven), people who haven't

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Ian Kelly
On Thu, Nov 2, 2017 at 10:27 AM, Israel Brewster wrote: > >> On Nov 1, 2017, at 4:53 PM, Steve D'Aprano >> wrote: >> >> On Thu, 2 Nov 2017 05:53 am, Israel Brewster wrote: >> >> [...] >>> So the end result is that the thread that "updates" the

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Grant Edwards
On 2017-11-03, Chris Angelico wrote: > On Sat, Nov 4, 2017 at 2:45 AM, Steve D'Aprano > wrote: >> So, all else being equal, which is likely to have more bugs? >> >> >> 1. Multiprocessing code with very little coupling between processes; or >> >> 2.

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Chris Angelico
On Sat, Nov 4, 2017 at 2:45 AM, Steve D'Aprano wrote: > So, all else being equal, which is likely to have more bugs? > > > 1. Multiprocessing code with very little coupling between processes; or > > 2. Threaded code with shared data and hence higher coupling between

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Steve D'Aprano
On Sat, 4 Nov 2017 01:50 am, Chris Angelico wrote: > On Fri, Nov 3, 2017 at 10:26 PM, Rhodri James wrote: >> I'm with Steven. To be fair, the danger with threads is that most people >> don't understand thread-safety, and in particular don't understand either >> that they

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Rhodri James
On 03/11/17 14:50, Chris Angelico wrote: On Fri, Nov 3, 2017 at 10:26 PM, Rhodri James wrote: On 02/11/17 20:24, Chris Angelico wrote: Thank you. I've had this argument with many people, smart people (like Steven), people who haven't grokked that all concurrency has

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Chris Angelico
On Fri, Nov 3, 2017 at 10:26 PM, Rhodri James wrote: > On 02/11/17 20:24, Chris Angelico wrote: >> >> Thank you. I've had this argument with many people, smart people (like >> Steven), people who haven't grokked that all concurrency has costs - >> that threads aren't

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Rhodri James
On 02/11/17 20:24, Chris Angelico wrote: Thank you. I've had this argument with many people, smart people (like Steven), people who haven't grokked that all concurrency has costs - that threads aren't magically more dangerous than other options. I'm with Steven. To be fair, the danger with

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Steve D'Aprano
On Fri, 3 Nov 2017 02:32 pm, Stefan Ram wrote: > Here is an excerpt from a text from Edward E. Lee: > > A part of the Ptolemy Project experiment was to see > whether effective software engineering practices could be > developed for an academic research setting. [...] > No problems were

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Steve D'Aprano
On Fri, 3 Nov 2017 02:19 pm, Rustom Mody wrote: > «The world is concurrent» [Joe Armstrong creator of Erlang] And the world is extremely complex, complicated and hard to understand. The point of programming is to simplify the world, not emulate it in its full complexity. -- Steve “Cheer

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Rustom Mody
On Friday, November 3, 2017 at 6:28:28 AM UTC+5:30, Steve D'Aprano wrote: > On Fri, 3 Nov 2017 07:24 am, Chris Angelico wrote: > > > On Fri, Nov 3, 2017 at 3:27 AM, Israel Brewster wrote: > >> > >> Actually, that saying is about regular expressions, not threads :-) . In > >> the end, threads are

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Steve D'Aprano
On Fri, 3 Nov 2017 07:24 am, Chris Angelico wrote: > On Fri, Nov 3, 2017 at 3:27 AM, Israel Brewster > wrote: >> >> Actually, that saying is about regular expressions, not threads :-) . In >> the end, threads are as good a way as handling concurrency as any other, >> and

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Chris Angelico
On Fri, Nov 3, 2017 at 3:27 AM, Israel Brewster wrote: > > Actually, that saying is about regular expressions, not threads :-) . In the > end, threads are as good a way as handling concurrency as any other, and > simpler than many. They have their drawbacks, of course,

Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Israel Brewster
> On Nov 1, 2017, at 4:53 PM, Steve D'Aprano wrote: > > On Thu, 2 Nov 2017 05:53 am, Israel Brewster wrote: > > [...] >> So the end result is that the thread that "updates" the dictionary, and the >> thread that initially *populates* the dictionary are actually

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 05:53 am, Israel Brewster wrote: [...] > So the end result is that the thread that "updates" the dictionary, and the > thread that initially *populates* the dictionary are actually running in > different processes. If they are in different processes, that would explain why the

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
On Nov 1, 2017, at 9:58 AM, Ian Kelly wrote: > > On Tue, Oct 31, 2017 at 11:38 AM, Israel Brewster > wrote: >> A question that has arisen before (for example, here: >> https://mail.python.org/pipermail/python-list/2010-January/565497.html >>

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Ian Kelly
On Tue, Oct 31, 2017 at 11:38 AM, Israel Brewster wrote: > A question that has arisen before (for example, here: > https://mail.python.org/pipermail/python-list/2010-January/565497.html > ) is > the

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
On Nov 1, 2017, at 9:04 AM, Israel Brewster wrote: > > Let me rephrase the question, see if I can simplify it. I need to be able to > access a defaultdict from two different threads - one thread that responds to > user requests which will populate the dictionary in

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
Let me rephrase the question, see if I can simplify it. I need to be able to access a defaultdict from two different threads - one thread that responds to user requests which will populate the dictionary in response to a user request, and a second thread that will keep the dictionary updated as

Thread safety issue (I think) with defaultdict

2017-10-31 Thread Israel Brewster
A question that has arisen before (for example, here: https://mail.python.org/pipermail/python-list/2010-January/565497.html ) is the question of "is defaultdict thread safe", with the answer generally being a conditional