Python 3.2 | WIndows 7 -- Multiprocessing and files not closing
mapoe
matthias at kill.at
Thu Oct 10 19:16:07 EDT 2013
On Thu, 10 Oct 2013 08:31:21 -0700, Isaac Gerg wrote:
> I have a function that looks like the following:
>
> #---------------------------------
> filename = 'c:\testfile.h5'
> f = open(filename,'r')
> data = f.read()
it seems kind of obvious from your sample:
add: f.close()
> q = multiprocessing.Queue()
> p = multiprocess.Process(target=myFunction,args=(data,q))
> p.start()
> result = q.get()
> p.join()
> q.close()
>
> f.close()
>
> os.remove(filename)
> #---------------------------------
>
> When I run this code, I get an error on the last line when I try to
> remove the file. It tells me that someone has access to the file. When
> I remove the queue and multiprocessing stuff, the function works fine.
>
> What is going on here?
>
> Thanks in advance,
> Isaac
More information about the Python-list
mailing list