×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    6

    python interpreter crashes with too many imports?

    following code( well just a part) causes the interpreter to crash
    Code:
    import e32, appuifw, positioning, urllib, graphics
    from socket import *
    if i remove the graphics module, it works fine

    the graphics module also works fine independently.

    i am using Nokia 5800 XM...seems like a RAM issue to me...

    any ideas/suggestions are welcome

  2. #2
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: python interpreter crashes with too many imports?

    welcome to the Python Board.

    Your code using many modules, So, probably it might have the memory loading issues.
    So , remove unused modules from the program.

    Best regards,

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    6

    Re: python interpreter crashes with too many imports?

    Thanks for replying...
    But the problem is that i don't import modules unless i really need them..
    Or is there a way i can run two different python scripts simultaneously?
    Can you confirm whether this is a memory issue?

  4. #4
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: python interpreter crashes with too many imports?

    You can try the same .py example project in other higher end Nokia device, which has more RAM, So,it will give us clear idea if any memory usage problem.

    Best regards,

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    20

    Re: python interpreter crashes with too many imports?

    Hi all,

    I have many troubles with the "import" and threads. The only way to have it working and not freezing is to make all the imports in the main thread. At least for me.

    So, if you have many threads, try (if possible) to make all the import at the begin in your main thread.

    This is with PyS60 2.0.0. With the previous 1.4.x, all was ok on a N95.

    HTH.

    Have a nice day.

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

    Re: python interpreter crashes with too many imports?

    i dont know i import around 13 modules and it works well (more or less) and a few additional modules in the modules

  7. #7
    Registered User
    Join Date
    Mar 2010
    Posts
    6

    Re: python interpreter crashes with too many imports?

    @AJ are u talkin about default python modules or ur own custom modules? and which phone do u use?
    @bornet I am not using any threads at all

    I noticed that the positioning module has an "import e32" of its own. Similarly the urllib module has an "import socket" of its own. I tried removing e32 and socket from my script but it wont work (need to study namespaces in depth) Am i duplicating resources if i import e32 and socket after importing urllib and positioning?

    I also tried using "from urllib import urlretrieve" etc hoping that the interpreter might not import other functions(does it work that way???) that i dont need but to no avail..it still crashed...
    Ideas, anyone?

  8. #8
    Regular Contributor
    Join Date
    May 2007
    Posts
    75

    Re: python interpreter crashes with too many imports?

    Quote Originally Posted by jinn_29 View Post
    Am i duplicating resources if i import e32 and socket after importing urllib and positioning?
    No, Python will load a module only once (on the first import statement), so you're not loading the same module into memory twice.

    Quote Originally Posted by jinn_29 View Post
    I also tried using "from urllib import urlretrieve" etc hoping that the interpreter might not import other functions(does it work that way???)
    Import from still imports the entire module (a module is not divisible, consider for example what would happen if urlretrieve requires another method from the urllib module), but then goes on to bind the names after 'import' into the local namespace instead of in the module namespace. So you can write urlretrieve instead of urllib.urlretrieve.

    See http://docs.python.org/release/2.5.2/ref/import.html

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

    Re: python interpreter crashes with too many imports?

    2 custom modules written in python which import only python standart modules
    so everything is python based.
    N82 -> anough ram

  10. #10
    Registered User
    Join Date
    Mar 2010
    Posts
    6

    Re: python interpreter crashes with too many imports?

    thanks, mwibbels and aj
    i had to do away with the GUI and though my app works, its kind of geeky for normal people to use...

Similar Threads

  1. Need python interpreter for N80.
    By ANANDHAJOTHI in forum Symbian
    Replies: 2
    Last Post: 2010-09-02, 08:53
  2. Upgrading python interpreter
    By maheshd13 in forum Mobile Web Server
    Replies: 1
    Last Post: 2009-08-06, 06:26
  3. Python Interpreter on n79
    By evanssthomas in forum Symbian
    Replies: 3
    Last Post: 2009-02-23, 04:23
  4. Insatallation drive and python interpreter
    By nufun in forum Symbian
    Replies: 7
    Last Post: 2008-09-10, 17:06
  5. When interpreter crashes...
    By lgmenu in forum Symbian
    Replies: 2
    Last Post: 2008-05-07, 04:34

Posting Permissions

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