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:
- boto3_sync_call: Synchronous boto3 client calls
- potential_boto3_sync: Potential boto3 operations
- sync_session_usage: Using Session instead of AsyncSession
- sync_db_operation: Synchronous database operations
- sync_file_operation: Blocking file I/O
- 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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bloky-0.1.2.tar.gz | 4.7 kB | Without provenance | Details for bloky-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bloky-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for bloky-0.1.2-py3-none-any.whl |
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
|
Security for bloky 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.