← Back to team overview

openerp-community team mailing list archive

Re: Reload openerp modules in running server

 

I had made some tweaks on the __init__.py in order to fire up a new thread that watch for a file, in case it find it it will reload the python module

this is the code:

import notebook
import os
from threading import Thread
import time
import sys, traceback

import logging

_logger = logging.getLogger('notebook')

filename="/usr/local/openerp/6.1/devel/openerp/addons/notebook/refresh.txt"

# Define thread behaivour
class myreload(Thread):
def __init__ (self):
Thread.__init__(self)
def run(self):
while 1:
if os.path.exists(filename):
_logger.critical('reload')
os.remove(filename)
try:
reload(notebook)
except Exception:
_logger.critical('shit happens')
exc_type, exc_value, exc_traceback = sys.exc_info()
_logger.critical(repr(traceback.extract_tb(exc_traceback)))
time.sleep(1)

# Create thread
_myreload = myreload()
# Start thread
_myreload.start()

and when i create a refresh.txt file i got:

2012-04-03 23:13:08,829 26646 CRITICAL ? notebook: reload

and when shit happens:

2012-04-03 23:13:16,839 26646 CRITICAL ? notebook: reload
2012-04-03 23:13:16,840 26646 CRITICAL ? notebook: shit happens
2012-04-03 23:13:16,840 26646 CRITICAL ? notebook: [('/usr/local/openerp/6.1/devel/openerp/addons/notebook/__init__.py', 23, 'run', 'reload(notebook)'), ('/usr/local/openerp/6.1/devel/openerp/addons/notebook/notebook.py', 4, '<module>', 'arst')]

i fixed the file and then it reloads again:

2012-04-03 23:13:55,885 26646 CRITICAL ? notebook: reload

off coure it only works for reloading python classes since .xml files are reloaded when i upgrade a module., so i just put the refresh.txt and have another tab with the modules page and reload !

Regarding your question: i have a quad core i5 3.1 Ghz 64 bits with 16 GB ram, enought to play more than fine with openerp, the problem is not restarting the server , the problem is waiting a half minute for the gears to finish moving on the chrome browser screen every time i restart the server and go to the modules section.

Anyway other python based systems like zope and django supports reloading for development environment, why openerp don't ?

Slds.

--
Nestor

On 04/03/2012 04:12 PM, Alexandre da Costa Leitão wrote:
Hi Nestor,

I think that’s not possible but, let me ask you something, here it doesn't take too much to restart the server? Is kind of fast and easy… you can create a script to do it or just click stop and start on eclipse… What hardware are you using?

Regards,
ribbon ball
	*Alexandre Leitão, Owner
**OpenERP Ready Partner*
Tel: (011) 3744-3170 | Mobile: (011) 8435-7021
www.infonetware.com.br <http://www.infonetware.com.br/>
twitter facebook linkedin


On 03/04/12 16:32, "Nestor Diaz" <nestor.at.tiendalinux@xxxxxxxxx <mailto:nestor.at.tiendalinux@xxxxxxxxx>> wrote:

    there any way to 'reload' the whole server instead of 'restart' the
    server ? something that could be faster to deal with ? like zope debu




Follow ups

References