semvec/pypi-packages huggingface dataset:
pulsar-asyncio-client 0.1.0
Wrapper for pulsar-client that publishes messages asynchronously and handles consumed messages in an asyncio event loop
License: MIT
Requires Python: >=3.8

# Pulsar AsyncIO Client

Wrapper for `pulsar-client` that publishes messages asynchronously and handles consumed messages in an `asyncio` event loop.

## Installation

```shell
$ pip install pulsar-asyncio-client
```

## Usage

```python
import asyncio
import pulsar_asyncio

PULSAR_URL = 'pulsar://localhost:6650'
PULSAR_TOPIC = 'non-persistent://public/default/my-topic'
PULSAR_SUBSCRIPTION = 'my-sub'

async def handle_message_async(consumer, message):
    message_text = message.data().decode('utf-8')
    print(f"Started asynchronously handling message: {message_text}")
    await asyncio.sleep(0.1)
    print(f"Finished asynchronously handling message: {message_text}")
    consumer.acknowledge(message)

async def main():
    # Init Pulsar client
    client = pulsar_asyncio.Client(PULSAR_URL)
    
    # Start a consumer with an async message listener
    consumer = client.subscribe(
        PULSAR_TOPIC,
        subscription_name=PULSAR_SUBSCRIPTION,
        message_listener=handle_message_async
    )

    # Asynchronously publish some messages
    producer = await client.create_producer(PULSAR_TOPIC)
    for i in range(10):
        message_text = f"My Message #{i}"
        print(f"About to asynchronously publish message: {message_text}")
        await producer.send(message_text.encode('utf-8'))

    # Allow some time for all messages to be consumed
    await asyncio.sleep(1)

    # Stop consumer
    consumer.close()
    
    # Stop client
    await client.close()

if __name__ == '__main__':
    asyncio.run(main())
```
cassandra-asyncio-driver 0.1.4
Wrapper for cassandra-driver that makes queries awaitable using asyncio
License: MIT
Requires Python: >=3.8

# Cassandra AsyncIO Driver

Wrapper for `cassandra-driver` that makes blocking calls awaitable using `asyncio`

## Installation

```shell
$ pip install cassandra-asyncio-driver
```

## Usage

To adapt existing code to use the asyncio driver, replace:
```python
from cassandra.cluster import Cluster
```

with:
```python
from cassandra_asyncio.cluster import Cluster
```

Queries can be executed asynchronously using `await session.aexecute()`.

For synchronous queries, `session.execute()` can still be used as normal.

All other Cassandra classes should continue to be imported from the usual paths.

For example:
```python
import csv
import asyncio
from cassandra_asyncio.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from cassandra.query import dict_factory

async def main():
    with open('movies.csv', 'w', newline='') as output_file:
        # Prepare CSV writer
        fieldnames = ['genre', 'name', 'rating', 'seen']
        writer = csv.DictWriter(output_file, fieldnames=fieldnames, dialect='excel')
        writer.writeheader()

        # Connect to Cassandra using `cassandra_asyncio.cluster.Cluster`
        auth_provider = PlainTextAuthProvider(username='cassandra', password='cassandra')
        cluster = Cluster(auth_provider=auth_provider)
        session = cluster.connect('lists')
        session.row_factory = dict_factory

        # Execute query asynchronously using `session.aexecute()`
        rows = await session.aexecute('SELECT genre, name, rating, seen FROM movies_to_watch')

        # Write rows to output file
        for row in rows:
            writer.writerow(row)

if __name__ == '__main__':
    asyncio.run(main())
```