Crossbar, Python3 & Postgres

#1

Hi,

I’m using Python3 and was following http://crossbar.io/docs/Database-Programming-with-PostgreSQL, but it looks like txpostgres does not work with Python3.

I’ve tried aiopg, but it looks like it only works correctly with asyncio. I’ve tried to substitute autobahn.twisted.wamp.ApplicationSession for autobahn.asyncio.wamp.ApplicationSession but that results in the error “builtins.AttributeError: ‘Deferred’ object has no attribute ‘set_result’”. Am I correct that an asyncio session can only be run from another host process and not directly from “crossbar start”?

What would be the best route to take here? Just use a separate autobahn.asyncio.wamp.ApplicationRunner to spawn the asyncio components, or am I missing something?

Thanks!

0 Likes

#2

Hi Wesley!

AFAIK asyncio sessions can be run using Crossbar as guests, but not in containers, since the latter require the same Python runtime and stack as Crossbar itself (i.e. Twisted).

Regards,

Alex

···

Am Montag, 19. Oktober 2015 20:54:08 UTC+2 schrieb Wesley Elfring:

Hi,

I’m using Python3 and was following http://crossbar.io/docs/Database-Programming-with-PostgreSQL, but it looks like txpostgres does not work with Python3.

I’ve tried aiopg, but it looks like it only works correctly with asyncio. I’ve tried to substitute autobahn.twisted.wamp.ApplicationSession for autobahn.asyncio.wamp.ApplicationSession but that results in the error “builtins.AttributeError: ‘Deferred’ object has no attribute ‘set_result’”. Am I correct that an asyncio session can only be run from another host process and not directly from “crossbar start”?

What would be the best route to take here? Just use a separate autobahn.asyncio.wamp.ApplicationRunner to spawn the asyncio components, or am I missing something?

Thanks!

0 Likes

#3

Ah, that’s what I thought. Thanks for your answer, Alexander.

What is currently the best way to connect a database using Python3 and Crossbar so I can use them inside of an container currently? Is there a downside on running those components as guests?

  • Wesley
···

On Tuesday, October 20, 2015 at 11:29:44 AM UTC+2, Alexander Gödde wrote:

Hi Wesley!

AFAIK asyncio sessions can be run using Crossbar as guests, but not in containers, since the latter require the same Python runtime and stack as Crossbar itself (i.e. Twisted).

Regards,

Alex

Am Montag, 19. Oktober 2015 20:54:08 UTC+2 schrieb Wesley Elfring:

Hi,

I’m using Python3 and was following http://crossbar.io/docs/Database-Programming-with-PostgreSQL, but it looks like txpostgres does not work with Python3.

I’ve tried aiopg, but it looks like it only works correctly with asyncio. I’ve tried to substitute autobahn.twisted.wamp.ApplicationSession for autobahn.asyncio.wamp.ApplicationSession but that results in the error “builtins.AttributeError: ‘Deferred’ object has no attribute ‘set_result’”. Am I correct that an asyncio session can only be run from another host process and not directly from “crossbar start”?

What would be the best route to take here? Just use a separate autobahn.asyncio.wamp.ApplicationRunner to spawn the asyncio components, or am I missing something?

Thanks!

0 Likes

#4

Hi Wesley!

The main difference is that with containers you can do the connection to Crossbar via the configuration file, while for guests the connection needs to be established from within the guest - so you have a bit more code in the guest. Otherwise there are no real downsides.

Regards,

Alex

···

Am Dienstag, 20. Oktober 2015 11:47:26 UTC+2 schrieb Wesley Elfring:

Ah, that’s what I thought. Thanks for your answer, Alexander.

What is currently the best way to connect a database using Python3 and Crossbar so I can use them inside of an container currently? Is there a downside on running those components as guests?

  • Wesley

On Tuesday, October 20, 2015 at 11:29:44 AM UTC+2, Alexander Gödde wrote:

Hi Wesley!

AFAIK asyncio sessions can be run using Crossbar as guests, but not in containers, since the latter require the same Python runtime and stack as Crossbar itself (i.e. Twisted).

Regards,

Alex

Am Montag, 19. Oktober 2015 20:54:08 UTC+2 schrieb Wesley Elfring:

Hi,

I’m using Python3 and was following http://crossbar.io/docs/Database-Programming-with-PostgreSQL, but it looks like txpostgres does not work with Python3.

I’ve tried aiopg, but it looks like it only works correctly with asyncio. I’ve tried to substitute autobahn.twisted.wamp.ApplicationSession for autobahn.asyncio.wamp.ApplicationSession but that results in the error “builtins.AttributeError: ‘Deferred’ object has no attribute ‘set_result’”. Am I correct that an asyncio session can only be run from another host process and not directly from “crossbar start”?

What would be the best route to take here? Just use a separate autobahn.asyncio.wamp.ApplicationRunner to spawn the asyncio components, or am I missing something?

Thanks!

0 Likes