Skip to main content

Bloky

A Python tool that analyzes Python code to detect blocking operations that could impact performance in async contexts.

Features

  • Boto3 Detection: Identifies synchronous boto3 client calls
  • Database Session Detection: Finds usage of synchronous Session instead of AsyncSession
  • File Operations: Detects blocking file I/O operations
  • Network Calls: Identifies synchronous HTTP requests
  • Recursive Scanning: Analyzes all Python files in directories and subdirectories
  • Detailed Reporting: Provides comprehensive reports with code snippets

Installation

Install from source (development)

pip install -e .

Install from PyPI (when published)

pip install bloky

Usage

After installation, you can use the bloky command from anywhere:

Analyze a directory

bloky /path/to/your/project

Analyze a single file

bloky /path/to/file.py

Save report to file

bloky /path/to/project --output blocking_report.txt

Alternative: Run directly without installation

python main.py /path/to/your/project

Detected Issues

The analyzer detects several types of blocking operations:

  1. boto3_sync_call: Synchronous boto3 client calls
  2. potential_boto3_sync: Potential boto3 operations
  3. sync_session_usage: Using Session instead of AsyncSession
  4. sync_db_operation: Synchronous database operations
  5. sync_file_operation: Blocking file I/O
  6. sync_network_call: Synchronous HTTP requests

Example Output

🚨 BLOCKING OPERATIONS DETECTED
==================================================

SUMMARY:
  boto3_sync_call: 2 occurrences
  sync_session_usage: 1 occurrences

BOTO3 SYNC CALL:
------------------------------
  📍 /path/to/file.py:15
     Synchronous boto3 client call detected
     Code: scheduler = get_boto_client("scheduler")
            target = {"Arn": arn, "Input": state_input, "RoleArn": role_arn}
            schedule = scheduler.create_schedule(

SYNC SESSION USAGE:
------------------------------
  📍 /path/to/file.py:45
     Using synchronous Session instead of AsyncSession
     Code: def playbook_list_get(
            self,
            request: Request,
            satori_db: Session,

Examples of Detected Patterns

Boto3 Synchronous Calls

# This will be detected
scheduler = get_boto_client("scheduler")
schedule = scheduler.create_schedule(...)

Database Session Issues

# This will be detected - using Session instead of AsyncSession
def some_function(self, satori_db: Session):
    result = satori_db.query(Model).all()

File Operations

# This will be detected
with open('file.txt') as f:
    content = f.read()  # Blocking read operation

Network Calls

# This will be detected
import requests
response = requests.get('https://api.example.com')  # Blocking HTTP call

Metadata

Release files for bloky 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bloky 0.1.2
File Size Uploaded
bloky-0.1.2.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bloky 0.1.2
File Interpreter ABI Platform
bloky-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / bloky-0.1.2.tar.gz

Download URL bloky-0.1.2.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f918743dcaf045b44471f5ab692c0fb91ee57696d69de32bcc51fed8793fb6dc
BLAKE2b-256 checksum
How to use checksums
baa38b8895074376d4852f9bb91ed4d7e2dd8d27b0a3ed88bd73313bf84dbf4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.5

Release files / bloky-0.1.2-py3-none-any.whl

Download URL bloky-0.1.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7397494bc1aa46fae46f75a19d95d54189e9ab22cf795164c69fc81678f1583e
BLAKE2b-256 checksum
How to use checksums
0033c7366287b2cd4437ad0da3fed34cd6e0401577461e9da2b914f844c8cfed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.5

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page