~stephane-openerp/openobject-server/python_lib

« back to all changes in this revision

Viewing changes to bin/service/netrpc_server.py

  • Committer: Stephane Wirtel
  • Date: 2010-01-31 21:49:48 UTC
  • Revision ID: stephane@openerp.com-20100131214948-a3p93d5ml7tir1f0
[REF] Extract the Logger class from the netsvc module

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    
25
25
"""
26
26
import netsvc
 
27
import logger
27
28
import threading
28
29
import tools
29
30
import os
30
31
import socket
 
32
import tools.misc
31
33
 
32
34
import tiny_socket
33
35
class TinySocketClientThread(threading.Thread, netsvc.OpenERPDispatcher):
69
71
                ts.mysend(result)
70
72
            except netsvc.OpenERPDispatcherException, e:
71
73
                try:
72
 
                    new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling
 
74
                    new_e = Exception(tools.misc.exception_to_unicode(e.exception)) # avoid problems of pickeling
73
75
                    ts.mysend(new_e, exception=True, traceback=e.traceback)
74
76
                except:
75
77
                    self.running = False
76
78
                    break
77
79
            except Exception, e:
78
80
                # this code should not be reachable, therefore we warn
79
 
                netsvc.Logger().notifyChannel("net-rpc", netsvc.LOG_WARNING, "exception: %s" % str(e))
80
 
                break
 
81
                logger.Logger().notifyChannel("net-rpc", logger.LOG_WARNING, "exception: %s" % str(e))
 
82
                raise
 
83
                #break
81
84
 
82
85
        self.threads.remove(self)
83
86
        self.running = False
98
101
        self.socket.bind((self.__interface, self.__port))
99
102
        self.socket.listen(5)
100
103
        self.threads = []
101
 
        netsvc.Logger().notifyChannel("web-services", netsvc.LOG_INFO, 
 
104
        logger.Logger().notifyChannel("web-services", logger.LOG_INFO, 
102
105
                         "starting NET-RPC service at %s port %d" % (interface or '0.0.0.0', port,))
103
106
 
104
107
    def run(self):
115
118
                if (lt > 10) and (lt % 10 == 0):
116
119
                     # Not many threads should be serving at the same time, so log
117
120
                     # their abuse.
118
 
                     netsvc.Logger().notifyChannel("web-services", netsvc.LOG_DEBUG,
 
121
                     logger.Logger().notifyChannel("web-services", logger.LOG_DEBUG,
119
122
                        "Netrpc: %d threads" % len(self.threads))
120
123
            self.socket.close()
121
124
        except Exception, e:
122
 
            netsvc.Logger().notifyChannel("web-services", netsvc.LOG_WARNING,
 
125
            logger.Logger().notifyChannel("web-services", logger.LOG_WARNING,
123
126
                        "Netrpc: closing because of exception %s" % str(e))
124
127
            self.socket.close()
125
128
            return False