Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
tquota.Quota
is a lightweight processing timer module designed to monitor time effectively when running code on cloud platforms with quota limitations, such as Kaggle and Google Colab. These platforms impose a limit of x
hours of processing per session, the Quota
class allows users to set a processing quota time and a buffer time before the quota limit ends, ensuring efficient resource management.
gap_time
) based on the remaining session time when set to 'auto'
.gap_time
is set to 'auto'
, the system dynamically calculates the optimal gap before the session ends, ensuring efficient timing without the need for manual setup.The package tquota
includes a single class, Quota
, which has two main parameters and an optional one:
6h
. Represents the maximum processing time for the session.'auto'
. Represents the buffer time before the session closes, adjusted dynamically based on elapsed time.False
. Whether to enable logging or not.The time should be specified in a strict format, consisting of two parts: dw
, where:
d: Represents the time as digits
w: Represents the time unit with one character:
[ s: Seconds, m: Minutes, h: Hours, d: Days]
The Quota
class provides the following key methods:
time_up
:
True
: If the process has reached or exceeded the defined quota time.False
: If there is still time remaining within the quota limit.if qt.time_up():
print('Time limit reached.')
hastime
:
True
: If there is still time remaining before reaching the quota.False
: If the process has exceeded the quota time or is within the gap buffer.if qt.hastime():
print('There’s still time to process.')
remaining_time
:
"xh:xm:xs"
(e.g., "0h:10m:15s"
for 10 minutes and 15 seconds remaining).remaining = qt.remaining_time()
print(f'Remaining time: {remaining}')
You can install the package from PyPI using the following command:
pip install tquota
Alternatively, you can clone the repository and install the package directly:
git clone https://github.com/aljbri/tquota.git
cd tquota
pip install .
Import the Quota
class as follows:
from tquota import Quota
from tquota import Quota
import time
# Quota time is set for 1 minute and gap time is auto-adjusted
qt = Quota('1m')
# Set quota_time for 1 minute and gap_time for 30 seconds
# qt = Quota('1m', '30s')
for i in range(1000):
time.sleep(1)
if qt.time_up():
print('The process has reached the limited time.')
break
from tquota import Quota
import time
# Quota time is set for 1 minute and gap time is auto-adjusted
# qt = Quota('1m')
# Set quota_time for 1 minute and gap_time for 30 seconds
qt = Quota('1m', '30s')
for i in range(1000):
time.sleep(1)
if not qt.hastime():
print('The process has reached the limited time.')
break
The Quota
class may raise the following exceptions:
ValueError
: Raised for invalid time formats or non-positive time values.TypeError
: Raised if non-string values are provided for time parameters.AttributeError
: Raised if internal properties are accessed incorrectly.This project is licensed under the MIT License. See the LICENSE file for details.
quota
class.quota
class.gap_time
when it is set to 'auto'
, dynamically adjusting the buffer time based on the session duration.ValueError
, TypeError
, AttributeError
) for invalid inputs or improper usage.Contributions are welcome! If you have suggestions or improvements, please feel free to submit a pull request or open an issue.
For inquiries or feedback, please contact the author at mr.aljbri@gmail.com.
FAQs
A lightweight processing timer module for quota-based cloud environments.
We found that tquota 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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.