Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 03:26, Evuraan wrote: > Please consider this situation : > Each line in "massive_input.txt" need to be churned by the > "time_intensive_stuff" function, so I am trying to background it. What kind of "churning" is involved? If its compute intensive threading may not be the right answer

Re: [Tutor] threading for each line in a large file, and doing it right

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 09:27, Alan Gauld via Tutor wrote: >> for i in $(< massive_input.file); do >> time_intensive_stuff_in_bash i & disown >> : >> done > > Its the same except in bash you start a whole > new process so instead of using threading you > use concurrent. concurrent -> multiprocessin

[Tutor] Calling the same thread multiple times

2018-04-25 Thread Vagelis
Hello, Im creating a progress bar for applications that can keep track of a download in progress. The progress bar will be on a separate thread and will communicate with the main thread using delegates. Ive made the download and the progress bar part, all that remains is the connection between the

[Tutor] I'm attempting to code the barbershop problem in OS except with 3 barbers instead of one. Can anyone help rewrite my Barber1 and Barber2 classes so it just uses the functions already defined i

2018-04-25 Thread Michael Solan
class Barber: barberWorkingEvent = Event() def sleep(self): self.barberWorkingEvent.wait() def wakeUp(self): self.barberWorkingEvent.set() def cutHair(self, customer): #Set barber as busy self.barberWorkingEvent.clear() print '{0} is having a haircut from barber\n'.format(customer.name) HairCutting

Re: [Tutor] I'm attempting to code the barbershop problem...

2018-04-25 Thread Steven D'Aprano
Hi Michael and welcome. In future, please leave the Subject line as a BRIEF summary, and put the description of your problem in the body of the email. You said: > I'm attempting to code the barbershop problem in OS except > with 3 barbers instead of one. Can anyone help rewrite my Barber1 and >

Re: [Tutor] I'm attempting to code the barbershop problem...

2018-04-25 Thread Mats Wichmann
> What's the barbershop problem? a classic computer science puzzle which is essentially a process synchronization problem. it does help to spell out the problem you are trying to solve, however - we don't have the context the original poster is operating in.

[Tutor] Dict of Dict with lists

2018-04-25 Thread Kai Bojens
Hello everybody, I'm coming from a Perl background and try to parse some Exim Logfiles into a data structure of dictionaries. The regex and geoip part works fine and I'd like to save the email adress, the countries (from logins) and the count of logins. The structure I'd like to have: result = {

Re: [Tutor] Dict of Dict with lists

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 14:22, Kai Bojens wrote: > The structure I'd like to have: > > result = { > 'f...@bar.de': { > 'Countries': [DE,DK,UK] > 'IP': ['192.168.1.1','172.10.10.10'] > 'Count': [12] > } > } > ... > for line in logfile: >

Re: [Tutor] File handling Tab separated files

2018-04-25 Thread Niharika Jakhar
hi again when I #print (self.organismA) under the for x in self.results: , it results in what it is supposed to be. But when i print it in the below function, it gives some garbage value. Kindly let me know what is wrong. :) import functools import csv import time start =time.time() class B

Re: [Tutor] (no subject)

2018-04-25 Thread Mats Wichmann
On 12/31/1969 05:00 PM, wrote: > Hello everybody, > I'm coming from a Perl background and try to parse some Exim Logfiles into a > data structure of dictionaries. The regex and geoip part works fine and I'd > like to save the email adress, the countries (from logins) and the count of > logins. >

Re: [Tutor] Dict of Dict with lists

2018-04-25 Thread Kai Bojens
On 25/04/2018 –– 18:35:30PM +0100, Alan Gauld via Tutor wrote: > > ... > > for line in logfile: > > result = pattern.search(line) > Doesn't this overwrite your data structure? > I would strongly advise using another name. You are of course right. I accidentally shortened this name as

Re: [Tutor] (no subject)

2018-04-25 Thread Kai Bojens
On 25/04/2018 –– 12:19:28PM -0600, Mats Wichmann wrote: > I presume that's pseudo-code, since it's missing punctuation (commas > between elements) and the country codes are not quoted Yes, that was just a short pseudo code example of what I wanted to achieve. > you don't actually need to ch

[Tutor] Async TCP Server

2018-04-25 Thread Simon Connah
Hi, I've come up with an idea for a new protocol I want to implement in Python using 3.6 (or maybe 3.7 when that comes out), but I'm somewhat confused about how to do it in an async way. The way I understand it is that you have a loop that waits for an incoming request and then calls a function/m

Re: [Tutor] Async TCP Server

2018-04-25 Thread Leam Hall
On 04/25/2018 05:14 PM, Simon Connah wrote: Hi, I've come up with an idea for a new protocol I want to implement in Python using 3.6 (or maybe 3.7 when that comes out), but I'm somewhat confused about how to do it in an async way. The way I understand it is that you have a loop that waits for a