twisted postgresql · twisted postgresql jan urbanski [email protected] university of warsaw /...

19
Twisted PostgreSQL Jan Urba´ nski [email protected] University of Warsaw / Flumotion May 20, 2010 Jan Urba´ nski [email protected] (University of Warsaw / Flumotion) Twisted PostgreSQL May 20, 2010 1/9

Upload: others

Post on 23-Mar-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Twisted PostgreSQL

Jan [email protected]

University of Warsaw / Flumotion

May 20, 2010

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 1 / 9

Page 2: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Who’s interested

Who uses:

PostgreSQL

Python

Psycopg2

Twisted

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 2 / 9

Page 3: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Who’s interested

Who uses:

PostgreSQL

Python

Psycopg2

Twisted

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 2 / 9

Page 4: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Who’s interested

Who uses:

PostgreSQL

Python

Psycopg2

Twisted

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 2 / 9

Page 5: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Who’s interested

Who uses:

PostgreSQL

Python

Psycopg2

Twisted

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 2 / 9

Page 6: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Psycopg2

psycopg2 version 2.2.0 wraps asynchronous libpqAPI

the connection object exposes the file descriptor

the poll() method wraps asynchronouscommunication

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 3 / 9

Page 7: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Psycopg2

psycopg2 version 2.2.0 wraps asynchronous libpqAPI

the connection object exposes the file descriptor

the poll() method wraps asynchronouscommunication

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 3 / 9

Page 8: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Psycopg2

psycopg2 version 2.2.0 wraps asynchronous libpqAPI

the connection object exposes the file descriptor

the poll() method wraps asynchronouscommunication

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 3 / 9

Page 9: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Psycopg2 example

Going async

c u r = conn . c u r s o r ( )c u r . e x e c u t e ( ’ s e l e c t c o l from b i g ’ )w h i l e True :

s t a t e = conn . p o l l ( )i f s t a t e == POLL OK :

b r e a ke l i f s t a t e == POLL READ :

s e l e c t . s e l e c t ( [ conn . f i l e n o ( ) ] , [ ] , [ ] )e l i f s t a t e == POLL WRITE :

s e l e c t . s e l e c t ( [ ] , [ conn . f i l e n o ( ) ] , [ ] )p r i n t c u r . f e t c h a l l ( )

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 4 / 9

Page 10: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Twisted

event-driven network engine

has an asynchronous, single-threaded main loop

used to do threads for database access

no more threads using the new bindings (sweet!)

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 5 / 9

Page 11: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Twisted

event-driven network engine

has an asynchronous, single-threaded main loop

used to do threads for database access

no more threads using the new bindings (sweet!)

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 5 / 9

Page 12: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Twisted

event-driven network engine

has an asynchronous, single-threaded main loop

used to do threads for database access

no more threads using the new bindings (sweet!)

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 5 / 9

Page 13: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Twisted

event-driven network engine

has an asynchronous, single-threaded main loop

used to do threads for database access

no more threads using the new bindings (sweet!)

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 5 / 9

Page 14: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Other nice things

green threads

coroutines

seamless SQLAlchemy/Django integration

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 6 / 9

Page 15: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Other nice things

green threads

coroutines

seamless SQLAlchemy/Django integration

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 6 / 9

Page 16: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Other nice things

green threads

coroutines

seamless SQLAlchemy/Django integration

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 6 / 9

Page 17: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Linkies

http://initd.org/psycopg2/ - home of thepsycopg2 driver

http://twistedmatrix.com/ - home of Twisted

http://launchpad.net/txpostgres - drop-inreplacement for Twisted database API

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 7 / 9

Page 18: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …

Folks

Federico Di Gregorio

Daniele Varrazzo

yours truly

Jan Urbanski [email protected] (University of Warsaw / Flumotion)Twisted PostgreSQL May 20, 2010 8 / 9

Page 19: Twisted PostgreSQL · Twisted PostgreSQL Jan Urbanski j.urbanski@wulczer.org University of Warsaw / Flumotion May 20, 2010 Jan Urbanski j.urbanski@wulczer.org (University of …