Re: can't delete from a dictionary in a loop
- From: Hans Nowak <zephyrfalcon!NO_SPAM!@xxxxxxxxx>
- Date: Fri, 16 May 2008 17:28:44 -0400
Dan Upton wrote:
for pid in procs_dict:
if procs_dict[pid].poll() != None
# do the counter updates
del procs_dict[pid]
The problem:
RuntimeError: dictionary changed size during iteration
I don't know if the setup with the pids in a dictionary is the best way to manage a pool of processes... I'll leave it others, presumably more knowledgable, to comment on that. :-) But I can tell you how to solve the immediate problem:
for pid in procs_dict.keys():
...
Hope this helps!
--Hans
.
- Follow-Ups:
- Re: can't delete from a dictionary in a loop
- From: bruno.desthuilliers@xxxxxxxxx
- Re: can't delete from a dictionary in a loop
- References:
- can't delete from a dictionary in a loop
- From: Dan Upton
- can't delete from a dictionary in a loop
- Prev by Date: Re: save dictionary for later use?
- Next by Date: Re: save dictionary for later use?
- Previous by thread: can't delete from a dictionary in a loop
- Next by thread: Re: can't delete from a dictionary in a loop
- Index(es):
Relevant Pages
|