当前位置: 首页>>代码示例>>Python>>正文


Python Connection.__init__方法代码示例

本文整理汇总了Python中cassandra.connection.Connection.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.__init__方法的具体用法?Python Connection.__init__怎么用?Python Connection.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cassandra.connection.Connection的用法示例。


在下文中一共展示了Connection.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()
        self._iobuf = StringIO()
        self._write_queue = Queue()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)

        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if self.ssl_options:
            if not ssl:
                raise Exception("This version of Python was not compiled with SSL support")
            self._socket = ssl.wrap_socket(self._socket, **self.ssl_options)
        self._socket.settimeout(1.0)  # TODO potentially make this value configurable
        self._socket.connect((self.host, self.port))

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        self._read_watcher = gevent.spawn(lambda: self.handle_read())
        self._write_watcher = gevent.spawn(lambda: self.handle_write())
        self._send_options_message()
开发者ID:chjwang,项目名称:magnetodb,代码行数:27,代码来源:geventreactor.py

示例2: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()
        self._write_queue = Queue()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)

        sockerr = None
        addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
        for (af, socktype, proto, canonname, sockaddr) in addresses:
            try:
                self._socket = socket.socket(af, socktype, proto)
                if self.ssl_options:
                    self._socket = ssl.wrap_socket(self._socket, **self.ssl_options)
                self._socket.settimeout(1.0)
                self._socket.connect(sockaddr)
                sockerr = None
                break
            except socket.error as err:
                sockerr = err
        if sockerr:
            raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        self._read_watcher = gevent.spawn(self.handle_read)
        self._write_watcher = gevent.spawn(self.handle_write)
        self._send_options_message()
开发者ID:IChocolateKapa,项目名称:python-driver,代码行数:34,代码来源:geventreactor.py

示例3: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self._write_queue = Queue()

        sockerr = None
        addresses = socket.getaddrinfo(
            self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM
        )
        for (af, socktype, proto, canonname, sockaddr) in addresses:
            try:
                self._socket = socket.socket(af, socktype, proto)
                self._socket.settimeout(1.0)
                self._socket.connect(sockaddr)
                sockerr = None
                break
            except socket.error as err:
                sockerr = err
        if sockerr:
            raise socket.error(
                sockerr.errno,
                "Tried connecting to %s. Last error: %s" % (
                    [a[4] for a in addresses], sockerr.strerror)
            )

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        self._read_watcher = eventlet.spawn(lambda: self.handle_read())
        self._write_watcher = eventlet.spawn(lambda: self.handle_write())
        self._send_options_message()
开发者ID:kjy,项目名称:python-driver,代码行数:34,代码来源:eventletreactor.py

示例4: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)
        self.deque = deque()

        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._socket.connect((self.host, self.port))
        self._socket.setblocking(0)

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        self._read_watcher = libev.IO(self._socket._sock, libev.EV_READ, _loop, self.handle_read)
        self._write_watcher = libev.IO(self._socket._sock, libev.EV_WRITE, _loop, self.handle_write)
        with _loop_lock:
            self._read_watcher.start()
            self._write_watcher.start()

        self._send_options_message()

        # start the global event loop if needed
        if not _start_loop():
            # if the loop was already started, notify it
            with _loop_lock:
                _loop_notifier.send()
开发者ID:aholmberg,项目名称:python-driver,代码行数:32,代码来源:libevreactor.py

示例5: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()
        self._iobuf = StringIO()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)
        self.deque = deque()
        self._deque_lock = Lock()

        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if self.ssl_options:
            if not ssl:
                raise Exception("This version of Python was not compiled with SSL support")
            self._socket = ssl.wrap_socket(self._socket, **self.ssl_options)
        self._socket.settimeout(1.0)  # TODO potentially make this value configurable
        self._socket.connect((self.host, self.port))
        self._socket.setblocking(0)

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        with _loop_lock:
            self._read_watcher = libev.IO(self._socket._sock, libev.EV_READ, _loop, self.handle_read)
            self._write_watcher = libev.IO(self._socket._sock, libev.EV_WRITE, _loop, self.handle_write)

        self._send_options_message()

        self.__class__._connection_created(self)

        # start the global event loop if needed
        _start_loop()
        _loop_notifier.send()
开发者ID:codesnik,项目名称:python-driver,代码行数:37,代码来源:libevreactor.py

示例6: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)
        asyncore.dispatcher.__init__(self)

        self.connected_event = Event()

        self._callbacks = {}
        self.deque = deque()
        self.deque_lock = Lock()

        self._loop.connection_created(self)

        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((self.host, self.port))
        self.add_channel()

        if self.sockopts:
            for args in self.sockopts:
                self.socket.setsockopt(*args)

        self._writable = True
        self._readable = True

        # start the event loop if needed
        self._loop.maybe_start()
开发者ID:EnigmaCurry,项目名称:python-driver,代码行数:27,代码来源:asyncorereactor.py

示例7: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)
        asyncore.dispatcher.__init__(self)

        self.connected_event = Event()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)
        self.deque = deque()

        with _starting_conns_lock:
            _starting_conns.add(self)

        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((self.host, self.port))

        if self.sockopts:
            for args in self.sockopts:
                self.socket.setsockopt(*args)

        self._writable = True
        self._readable = True

        # start the global event loop if needed
        _start_loop()
开发者ID:Kami,项目名称:python-driver,代码行数:27,代码来源:asyncorereactor.py

示例8: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)
        asyncore.dispatcher.__init__(self)

        self.deque = deque()
        self.deque_lock = Lock()

        sockerr = None
        addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
        for (af, socktype, proto, canonname, sockaddr) in addresses:
            try:
                self.create_socket(af, socktype)
                self.connect(sockaddr)
                sockerr = None
                break
            except socket.error as err:
                sockerr = err
        if sockerr:
            raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))

        self.add_channel()

        if self.sockopts:
            for args in self.sockopts:
                self.socket.setsockopt(*args)

        self._writable = True
        self._readable = True

        # start the event loop if needed
        self._loop.maybe_start()
开发者ID:kjy,项目名称:python-driver,代码行数:33,代码来源:asyncorereactor.py

示例9: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)
        self._write_queue = Queue()

        self._connect_socket()

        self._read_watcher = eventlet.spawn(lambda: self.handle_read())
        self._write_watcher = eventlet.spawn(lambda: self.handle_write())
        self._send_options_message()
开发者ID:datastax,项目名称:python-driver,代码行数:11,代码来源:eventletreactor.py

示例10: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()
        self._write_queue = Queue()

        self._callbacks = {}
        self._push_watchers = defaultdict(set)

        self._connect_socket()

        self._read_watcher = eventlet.spawn(lambda: self.handle_read())
        self._write_watcher = eventlet.spawn(lambda: self.handle_write())
        self._send_options_message()
开发者ID:philippeback,项目名称:python-driver,代码行数:16,代码来源:eventletreactor.py

示例11: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.deque = deque()
        self.deque_lock = Lock()

        self._connect_socket()
        asyncore.dispatcher.__init__(self, self._socket, _dispatcher_map)

        self._writable = True
        self._readable = True

        self._send_options_message()

        # start the event loop if needed
        self._loop.maybe_start()
开发者ID:datastark,项目名称:python-driver,代码行数:18,代码来源:asyncorereactor.py

示例12: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        """
        Initialization method.

        Note that we can't call reactor methods directly here because
        it's not thread-safe, so we schedule the reactor/connection
        stuff to be run from the event loop thread when it gets the
        chance.
        """
        Connection.__init__(self, *args, **kwargs)

        self.is_closed = True
        self.connector = None

        reactor.callFromThread(self.add_connection)
        self._loop.maybe_start()
开发者ID:rainslytherin,项目名称:python-driver,代码行数:18,代码来源:twistedreactor.py

示例13: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self._connect_socket()
        self._socket.setblocking(0)

        self._write_queue = asyncio.Queue(loop=self._loop)

        # see initialize_reactor -- loop is running in a separate thread, so we
        # have to use a threadsafe call
        self._read_watcher = asyncio.run_coroutine_threadsafe(
            self.handle_read(), loop=self._loop
        )
        self._write_watcher = asyncio.run_coroutine_threadsafe(
            self.handle_write(), loop=self._loop
        )
        self._send_options_message()
开发者ID:datastax,项目名称:python-driver,代码行数:19,代码来源:asyncioreactor.py

示例14: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.deque = deque()
        self._deque_lock = Lock()
        self._connect_socket()
        self._socket.setblocking(0)

        with self._libevloop._lock:
            self._read_watcher = libev.IO(self._socket.fileno(), libev.EV_READ, self._libevloop._loop, self.handle_read)
            self._write_watcher = libev.IO(self._socket.fileno(), libev.EV_WRITE, self._libevloop._loop, self.handle_write)

        self._send_options_message()

        self._libevloop.connection_created(self)

        # start the global event loop if needed
        self._libevloop.maybe_start()
开发者ID:coldeasy,项目名称:python-driver,代码行数:20,代码来源:libevreactor.py

示例15: __init__

# 需要导入模块: from cassandra.connection import Connection [as 别名]
# 或者: from cassandra.connection.Connection import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self.connected_event = Event()

        self._callbacks = {}
        self.deque = deque()
        self._deque_lock = Lock()

        sockerr = None
        addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
        for (af, socktype, proto, canonname, sockaddr) in addresses:
            try:
                self._socket = socket.socket(af, socktype, proto)
                if self.ssl_options:
                    if not ssl:
                        raise Exception("This version of Python was not compiled with SSL support")
                    self._socket = ssl.wrap_socket(self._socket, **self.ssl_options)
                self._socket.settimeout(1.0)  # TODO potentially make this value configurable
                self._socket.connect(sockaddr)
                sockerr = None
                break
            except socket.error as err:
                sockerr = err
        if sockerr:
            raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))

        self._socket.setblocking(0)

        if self.sockopts:
            for args in self.sockopts:
                self._socket.setsockopt(*args)

        with self._libevloop._lock:
            self._read_watcher = libev.IO(self._socket.fileno(), libev.EV_READ, self._libevloop._loop, self.handle_read)
            self._write_watcher = libev.IO(self._socket.fileno(), libev.EV_WRITE, self._libevloop._loop, self.handle_write)

        self._send_options_message()

        self._libevloop.connection_created(self)

        # start the global event loop if needed
        self._libevloop.maybe_start()
开发者ID:IChocolateKapa,项目名称:python-driver,代码行数:45,代码来源:libevreactor.py


注:本文中的cassandra.connection.Connection.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。