python类bind()的实例源码

netstream.py 文件源码 项目:5In1RowService 作者: caiwb 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def startup(self, port = 0, host = ''):
        self.shutdown()
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        try: self.sock.bind((host, port))
        except: 
            try: self.sock.close()
            except: pass
            return -1
        try: self.sock.listen(65536)
        except:
            try: self.sock.close()
            except: pass
            return -1
        self.sock.setblocking(0)
        self.port = self.sock.getsockname()[1]
        self.state = 1
        self.host = host
        self.timeslap = long(time.time() * 1000)
        return 0

    # shutdown service
emake.py 文件源码 项目:collection 作者: skywind3000 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _psyco_speedup():
    try:
        import psyco
        psyco.bind(preprocessor)
        psyco.bind(configure)
        psyco.bind(coremake)
        psyco.bind(emake)
        #print 'full optimaze'
    except:
        return False
    return True



#----------------------------------------------------------------------
# distribution
#----------------------------------------------------------------------
netstream.py 文件源码 项目:5In1RowService 作者: caiwb 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _psyco_speedup():
    try:
        import psyco
        psyco.bind(rc4crypt)
        psyco.bind(netstream)
        psyco.bind(nethost)
        psyco.bind(CCLIB)
    except:
        return False
    return True
gobang.py 文件源码 项目:collection 作者: skywind3000 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def psyco_speedup ():
    try:
        import psyco
        psyco.bind(chessboard)
        psyco.bind(evaluation)
    except:
        pass
    return 0
gamelevel.py 文件源码 项目:collection 作者: skywind3000 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def speedup():
    try:
        import psyco
        psyco.bind(disjointset)
        psyco.bind(vector2d)
        psyco.bind(line2d)
        psyco.bind(savebmp)
    except ImportError:
        pass


问题


面经


文章

微信
公众号

扫码关注公众号