report progress from C function

M

Michael S

Good day all.

I rewrote part of my program in C, it's a usually a
long task. I wanted to be able to report the progress
back to my python program. In my module (in addition
to the function that performs the above-mentioned
task) there is a function that returns the variable,
indicating the progress. However I am not sure how to
call it. Once I call the C function that does the work
(it's a while loop that takes minutes sometimes) I
can't call that progress function.
Any ideas?

Thanks in advance,
Michael
 
J

John Machin

Michael said:
Good day all.

I rewrote part of my program in C, it's a usually a
long task. I wanted to be able to report the progress
back to my python program. In my module (in addition
to the function that performs the above-mentioned
task) there is a function that returns the variable,
indicating the progress. However I am not sure how to
call it. Once I call the C function that does the work
(it's a while loop that takes minutes sometimes) I
can't call that progress function.
Any ideas?

What do you expect your "python program" to be doing between calls to
the get_progress function?

Here's a sketch of one possible way of doing something useful: add the
following 2 args to your C "does the work function":
(1) Python function object to be called every n times around the while
loop or every nth other event or every n milliseconds or whatever
(2) n

BTW, why did you rewrite in C rarher than using Pyrex?

Cheers,
John
 
F

Fredrik Lundh

Michael said:
I downloaded Pyrex and ran it through their own
example. The code looks quite messy, and I even saw a
few "goto"s.

looked at the assembler output from your C compiler lately?

</F>
 
H

Hendrik van Rooyen

Fredrik Lundh said:
looked at the assembler output from your C compiler lately?

</F>

LOL! - is it even possible to code an if else without conditional jumps?

- Hendrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top