Esempio n. 1
0
    def test_gevent_socket_pymssql_callproc_wait_read_concurrency(self):
        def wait_callback(read_fileno):
            gevent.socket.wait_read(read_fileno)

        pymssql.set_wait_callback(wait_callback)

        with pymssqlconn() as conn:
            cur = conn.cursor()
            proc_name = 'my_proc'
            cur.execute("IF OBJECT_ID('%s', 'P') IS NOT NULL DROP PROCEDURE %s" % (proc_name, proc_name))
            cur.execute("""
            CREATE PROCEDURE %s AS
            BEGIN
                SET NOCOUNT ON
                WAITFOR DELAY '00:00:05'  -- sleep for 5 seconds
                SELECT CURRENT_TIMESTAMP
            END
            """ % (proc_name,))
            conn.commit()

        elapsed_time = self._run_all_greenlets(
            self.greenlet_run_pymssql_callproc)

        self.assertTrue(
            elapsed_time < datetime.timedelta(seconds=20),
            'elapsed_time < 20 seconds')
Esempio n. 2
0
    def test_gevent_socket_pymssql_callproc_wait_read_concurrency(self):
        def wait_callback(read_fileno):
            gevent.socket.wait_read(read_fileno)

        pymssql.set_wait_callback(wait_callback)

        with pymssqlconn() as conn:
            cur = conn.cursor()
            proc_name = 'my_proc'
            cur.execute(
                "IF OBJECT_ID('%s', 'P') IS NOT NULL DROP PROCEDURE %s" %
                (proc_name, proc_name))
            cur.execute("""
            CREATE PROCEDURE %s AS
            BEGIN
                SET NOCOUNT ON
                WAITFOR DELAY '00:00:05'  -- sleep for 5 seconds
                SELECT CURRENT_TIMESTAMP
            END
            """ % (proc_name, ))
            conn.commit()

        elapsed_time = self._run_all_greenlets(
            self.greenlet_run_pymssql_callproc)

        self.assertTrue(elapsed_time < datetime.timedelta(seconds=20),
                        'elapsed_time < 20 seconds')
Esempio n. 3
0
    def test_gevent_socket_mssql_execute_wait_read_concurrency(self):
        def wait_callback(read_fileno):
            gevent.socket.wait_read(read_fileno)

        pymssql.set_wait_callback(wait_callback)

        elapsed_time = self._run_all_greenlets(self.greenlet_run_mssql_execute)

        self.assertTrue(elapsed_time < datetime.timedelta(seconds=20),
                        'elapsed_time < 20 seconds')
Esempio n. 4
0
    def test_gevent_socket_pymssql_execute_wait_read_concurrency(self):
        def wait_callback(read_fileno):
            gevent.socket.wait_read(read_fileno)

        pymssql.set_wait_callback(wait_callback)

        elapsed_time = self._run_all_greenlets(
            self.greenlet_run_pymssql_execute)

        self.assertTrue(
            elapsed_time < datetime.timedelta(seconds=20),
            'elapsed_time < 20 seconds')
Esempio n. 5
0
        gevent.sleep(1)
        greenlets.append(gevent.spawn(run, i))

    gevent.joinall(greenlets)

    dt2 = datetime.datetime.now()

    print("Done running - elapsed time: %s" % (dt2 - dt1))


print("**** Running test with NO wait_callback...\n")
do_test()

print("\n***** Running test WITH gevent.sleep wait_callback...\n")
def wait_callback(read_fileno):
    # print("    *** wait_callback called with read_fileno = %r" % (read_fileno,))
    gevent.sleep()

pymssql.set_wait_callback(wait_callback)

do_test()

print("\n***** Running test WITH gevent.socket.wait_read wait_callback...\n")
def wait_callback(read_fileno):
    # print("    *** wait_callback called with read_fileno = %r" % (read_fileno,))
    gevent.socket.wait_read(read_fileno)

pymssql.set_wait_callback(wait_callback)

do_test()