chtd / psycopg2cffi

Port to cffi with some speed improvements
Other
177 stars 43 forks source link

Replaced argument 'async' with 'async_' #103 #104

Closed donalm closed 4 years ago

donalm commented 6 years ago

I don't think that the _connect method that's getting called here needs to accept both async= and async_= keyword arguments, so there's an opportunity to avoid the creation of a dict. We can just pass a bool into the _connect method directly.

Note that _connect is already careful to not pass on an async_ argument unless async_'s value is True:

def _connect(dsn, connection_factory=None, async_=False):                       
    if connection_factory is None:                                              
        connection_factory = Connection                                         

    # Mimic the construction method as used by psycopg2, which notes:           
    # Here we are breaking the connection.__init__ interface defined            
    # by psycopg2. So, if not requiring an async conn, avoid passing            
    # the async_ parameter.                                                     
    if async_:                                                                  
        return connection_factory(dsn, async_=True)                             
    else:                                                                       
        return connection_factory(dsn)
lopuhin commented 6 years ago

Oh sorry never mind, I see that this is a fix for #103 now

thedrow commented 4 years ago

@lopuhin Can we merge this?

lopuhin commented 4 years ago

Merged, thanks @donalm and @thedrow