All pastes #253444 Raw Edit

Anonymous

public text v1 · immutable
#253444 ·published 2006-11-20 19:58 UTC
rendered paste body
@tasklet.task
def transfer_file(filein, fileout):

	print "copying!!!"

	#fin = open(filein, "r")
	#fout = open(fileout, "w")

	read_chan = gobject.IOChannel(filename=filein, mode="r")
	read_chan.set_flags(gobject.IO_FLAG_NONBLOCK)

	write_chan = gobject.IOChannel(filename=fileout, mode="w")
	write_chan.set_flags(gobject.IO_FLAG_NONBLOCK)

	while True:
		assert read_chan.get_flags() & gobject.IO_FLAG_IS_READABLE
		yield tasklet.WaitForIO(read_chan, gobject.IO_IN)
		tasklet.get_event()
		c = read_chan.read(BUFFER_SIZE)

		if not buf:
			break;

		assert write_chan.get_flags() & gobject.IO_FLAG_IS_WRITEABLE
		yield tasklet.WaitForIO(write_chan, gobject.IO_OUT)
		tasklet.get_event()
		write_chan.write(c)

	fin.close()
	fout.close()