×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Exclamation [help] complex problem (loops)

    i have a problem:

    i need to run loops (two or more) that do not block each other.
    Python first runs through one loop and if the first is finished it goes to the next one but i need to run two loops (while-loops) at the same time.

    Does anybody has any idea how to solve this problem ?

    e32.start_server(file) maybe ? If yes can somebody tell me if the server skript has access to all vars,strings,functions,modules like the mainskript from which the server was started ?

    i tried it already with "e32.start_server(file)" but it seems to block (slows down and do not render but main skript runs and is accessable) somehow my skript and i dont get any error message

    that's actualy the idea which i try to realize somehow:
    http://www.bilderload.com/bild/22255...annt118TGV.jpg

    black are skripts that already work fine without green/blue ones
    red are imports/imported modules
    green is the e32.start_server(file) that should do the render job and speed up the main skript
    blue are recources from other skripts

    can somebody explain me how to run a "e32.start_server(file)" that has access to everything what the main skript has ?

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: [help] complex problem (loops)

    Have you tried using threads?

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    i tried threads but the block the mainskript while they are executed ? at least for me they blocked the mainskript ...

    i dont know maybe i've done somethring wrong ???

    can you give me an example of how to use em rite , without blocking the mainskript ?

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    nobody has any experience with threads or e32.start_server() ???

  5. #5
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [help] complex problem (loops)

    Quote Originally Posted by AJ____92 View Post
    i tried threads but the block the mainskript while they are executed ? at least for me they blocked the mainskript ...
    Thread and python shell are not working as expected. See this thread, please.

    For threads I prefer to use python 1.9.x and threading module. It is easier to use.
    And remember that only the main thread may update the UI.

  6. #6
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    thx for the help :P

    i kinda managed it to create a thread that should render the 3D scene but i get no results from the thread

    that's my code i used:
    Code:
    ...
    fps = 30
    
    class renderer(Thread):
        def __init__(self):
            Thread.__init__(self)
    
        def run(self):
            global running
            while running:
                try:
                    canvas.drawNow()
                except:
                    running = 0
                e32.ao_sleep(1/fps)
    
    
    render_thread = renderer()
    render_thread.start()
    render_thread.join()
    if i write a simple while-loop and call there the canvas.drawNow() function it works perfectly.
    but i need it in a thread because the main skript gets slow with more objects to render.

    this code runs without any errors but it do not render to the screen ...
    screen just freezes and i can not press exit if the thread is started.

    i realy hope somebody can explain me how to start a thread xD

  7. #7
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    i repacked the python shellscript with mode=pycore but it still blocks the main skript

  8. #8
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [help] complex problem (loops)

    Hi AJ !

    I think we may have a problem here:

    Code:
    e32.ao_sleep(1/fps)
    In Python, if fps in an integer, we will have integer as result:

    Code:
    IDLE 2.6.4      ==== No Subprocess ====
    >>> 1/30
    0
    >>> 1/30.0
    0.033333333333333333
    >>> 1.0/30
    0.033333333333333333
    >>>
    Got it ? So, you may be calling ao_sleep with 0 instead expected float value.

  9. #9
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    hmm worked fine in the main-skript :P
    but i'll try that thx for ya help !!!

    EDIT:
    nope wasnt the problem...

    do i have to run the other loop in a thread too ?
    and do i have to use queues ?

    i kinda don't get it how to use them right without blocking other loops/functions
    Last edited by AJ____92; 2010-01-02 at 13:58.

  10. #10
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [help] complex problem (loops)

    Quote Originally Posted by AJ____92 View Post
    do i have to run the other loop in a thread too ?
    and do i have to use queues ?
    i kinda don't get it how to use them right without blocking other loops/functions
    Other loop ? Please, but it is becoming a guessing game
    It is better to post some code to open the discussion again.

  11. #11
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: [help] complex problem (loops)

    that would be tooooo much xD

    can i add you in MSN ?
    so we can talk a lil bit about threading ...
    i just need to understand how it works that's it.


    because i use 1 skript with 2 modules (selfmade but workin great) and 2 loops that need to run at the same time without blocking each other.

    Do i need to run them both (loops) in a thread ?
    Last edited by AJ____92; 2010-01-04 at 14:46. Reason: .

  12. #12
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: [help] complex problem (loops)

    Quote Originally Posted by AJ____92 View Post
    t
    because i use 1 skript with 2 modules (selfmade but workin great) and 2 loops that need to run at the same time without blocking each other.
    Do i need to run them both (loops) in a thread ?
    I am not sure which is the best approach
    But second one seems simpler, of course. A kind of polling.

    Quote Originally Posted by AJ____92 View Post
    can i add you in MSN ?
    so we can talk a lil bit about threading ...
    It is better to discuss it here, making the thread available to anyone. But sometime is really difficult to explain what is happening and some exceptions are interesting. If you think that it is necessary, you may try to contact me at gtalk (same login).

Similar Threads

  1. [help] about s60 3rd software setup problem
    By sala1987 in forum Symbian
    Replies: 2
    Last Post: 2007-10-29, 17:03
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36
  4. [help] problem with Series_60_MIDP_SDK_2_1
    By kevinpan in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2004-12-22, 03:31
  5. PJava runtime problem within Nokia 9210, Hrlp~!
    By Nokia_Archive in forum PersonalJava
    Replies: 1
    Last Post: 2002-05-28, 13:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •