Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A pure-python calendar queue and library for scheduling events with asyncio
.
Many other libraries allow for event/job scheduling but either they are not asynchronous or they are just fire-and-forget.
calendar-queue
has two purposes:
CalendarQueue
class in which events can be awaitedCalendar
class that simplifies the usage of CalendarQueue
.Depending on your needs, you can use one of the two to develop your own event manager/scheduler.
The idea is: we take care of emitting events at the right time, you write the logic for acting accordingly.
pip install calendar-queue
An example usage of CalendarQueue
import asyncio
from datetime import datetime
from random import randrange
from secrets import token_hex
from calendar_queue import CalendarQueue
# (optional) define the item type
CustomItem = tuple[str]
# use the low level calendar queue
cq: CalendarQueue[CustomItem] = CalendarQueue()
async def put_random():
print("Putting new items in the calendar queue. Hit CTRL + C to stop.")
while True:
# sleep for a while, just to release the task
await asyncio.sleep(1)
scheduled_ts = datetime.now().timestamp() + randrange(1, 5)
s = token_hex(8)
current_item: CustomItem = (s)
print(f"{datetime.now().isoformat()}: putting {current_item} scheduled for {datetime.fromtimestamp(scheduled_ts).isoformat()}")
cq.put_nowait((scheduled_ts, current_item))
async def get_from_queue():
while True:
ts, el = await cq.get()
print(f"{datetime.now().isoformat()}: getting {el} scheduled for {datetime.fromtimestamp(ts).isoformat()}")
async def main():
await asyncio.gather(
asyncio.create_task(put_random()),
asyncio.create_task(get_from_queue()),
)
if __name__ == "__main__":
asyncio.run(main())
This library is developed using Python 3.11 and pdm
as dependency manager.
Testing is done via github actions and it's done on python versions 3.10
, 3.11
, 3.12
and on latest ubuntu
, macos
, windows
OSes.
For local development you'll need to have pdm installed, then you can:
pdm install
to create the virtual environment and install the dependenciespdm venv activate
to activate the virtual environmentpytest
pylint src
Contributions are welcome! Especially for new tests and for improving documentation and examples.
The code in this project is released under the MIT License.
FAQs
A pure python calendar-queue based on asyncio
We found that calendar-queue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.