Module to handle graceful shutdowns

Module to handle applications’ graceful shutdowns.

This super simple module helps shutting down servers, database handles, etc. in NodeJS applications. It allows to register handlers for certain shutdown signals/events in order to attempt a graceful shutdown (clean-ups etc.)

NOTE: it removes any previous registered listeners for the given signals!

By default it listens to: SIGTERM SIGHUP SIGINT

It also listens to process.exit but keep in mind that exit does not allow asynchrounous listeners’ operations to complete (see process.exit on NodeJS.org)

It is also possible to add (or remove) other shutdown signals/events.

Install

npm i -S @hypercliq/shutdown-cleanup

Usage

Register a handler

import { ShutdownCleanup } from 'shutdown-cleanup'
// const ShutdownCleanup = require('shutdown-cleanup').ShutdownCleanup

ShutdownCleanup.registerHandler(() => console.log('This is printed on exit :)'))

Add a signal or event to listen to

ShutdownCleanup.addSignal('uncaughtException')

Remove a signal or an event

ShutdownCleanup.removeSignal('SIGHUP')

List signals and events listened to

ShutdownCleanup.listSignals()

TypeScript

TypeScript types are included.

Uncaught Exceptions & other similar events

It is possible to listen to the uncaughtException event, but no error message will be displayed if the handle function does not explicitly ask for it or we don’t enable debug (this is also true for other events such as unhandledRejection.)

Handle parameter
ShutdownCleanup.registerHandler((codeOrError) =>
  console.log('This what we got back:', codeOrError)
)

By accepting a parameter (in this case codeOrError) we can get back from the module either a code/signal or an error.

Debug

Another way to see what’s going on is to turn debug on:

DEBUG=shutdown-cleanup npm start

or Windows

set DEBUG=shutdown-cleanup & npm start

Download Details:

Author: hypercliq

Source Code: https://github.com/hypercliq/shutdown-cleanup

#nodejs #node #javascript

What is GEEK

Buddha Community

Module to handle graceful shutdowns
Ray  Patel

Ray Patel

1619571780

Top 20 Most Useful Python Modules or Packages

 March 25, 2021  Deepak@321  0 Comments

Welcome to my blog, In this article, we will learn the top 20 most useful python modules or packages and these modules every Python developer should know.

Hello everybody and welcome back so in this article I’m going to be sharing with you 20 Python modules you need to know. Now I’ve split these python modules into four different categories to make little bit easier for us and the categories are:

  1. Web Development
  2. Data Science
  3. Machine Learning
  4. AI and graphical user interfaces.

Near the end of the article, I also share my personal favorite Python module so make sure you stay tuned to see what that is also make sure to share with me in the comments down below your favorite Python module.

#python #packages or libraries #python 20 modules #python 20 most usefull modules #python intersting modules #top 20 python libraries #top 20 python modules #top 20 python packages

Ray  Patel

Ray Patel

1619615100

Python Collections Module: Counter, ChainMap, Deque & Tuple

Python Collections module offers a set of container data types that extend the features of stock containers like Lists, Tuples, Sets, and Dictionaries. With these special containers, you not only have the features of stock containers, but also some extra methods which come in very handy for certain tasks.

By the end of this tutorial, you’ll have the knowledge of the following:

  • What is the collections module?
  • Various functions like :
  1. Counter
  2. ChainMap
  3. Deque
  4. Named Tuple
  • Working examples

The Collections module comes pre-installed in Python so we don’t need to pip install it. We can just import it and you’re ready to go! Let’s go into the most used functions in detail.

#data science #collection #collection module #python #python collection module #python module

Python Collections Module: Counter, ChainMap, Deque & Tuple | upGrad blog

Python Collections module offers a set of container data types that extend the features of stock containers like Lists, Tuples, Sets, and Dictionaries. With these special containers, you not only have the features of stock containers, but also some extra methods which come in very handy for certain tasks.

By the end of this tutorial, you’ll have the knowledge of the following:

  • What is the collections module?
  • Various functions like :
  1. Counter
  2. ChainMap
  3. Deque
  4. Named Tuple
  • Working examples

The Collections module comes pre-installed in Python so we don’t need to pip install it. We can just import it and you’re ready to go! Let’s go into the most used functions in detail.

#data science #collection #collection module #python #python collection module #python module

Module to handle graceful shutdowns

Module to handle applications’ graceful shutdowns.

This super simple module helps shutting down servers, database handles, etc. in NodeJS applications. It allows to register handlers for certain shutdown signals/events in order to attempt a graceful shutdown (clean-ups etc.)

NOTE: it removes any previous registered listeners for the given signals!

By default it listens to: SIGTERM SIGHUP SIGINT

It also listens to process.exit but keep in mind that exit does not allow asynchrounous listeners’ operations to complete (see process.exit on NodeJS.org)

It is also possible to add (or remove) other shutdown signals/events.

Install

npm i -S @hypercliq/shutdown-cleanup

Usage

Register a handler

import { ShutdownCleanup } from 'shutdown-cleanup'
// const ShutdownCleanup = require('shutdown-cleanup').ShutdownCleanup

ShutdownCleanup.registerHandler(() => console.log('This is printed on exit :)'))

Add a signal or event to listen to

ShutdownCleanup.addSignal('uncaughtException')

Remove a signal or an event

ShutdownCleanup.removeSignal('SIGHUP')

List signals and events listened to

ShutdownCleanup.listSignals()

TypeScript

TypeScript types are included.

Uncaught Exceptions & other similar events

It is possible to listen to the uncaughtException event, but no error message will be displayed if the handle function does not explicitly ask for it or we don’t enable debug (this is also true for other events such as unhandledRejection.)

Handle parameter
ShutdownCleanup.registerHandler((codeOrError) =>
  console.log('This what we got back:', codeOrError)
)

By accepting a parameter (in this case codeOrError) we can get back from the module either a code/signal or an error.

Debug

Another way to see what’s going on is to turn debug on:

DEBUG=shutdown-cleanup npm start

or Windows

set DEBUG=shutdown-cleanup & npm start

Download Details:

Author: hypercliq

Source Code: https://github.com/hypercliq/shutdown-cleanup

#nodejs #node #javascript

Husam Abdullah

1597811895

Keras Modules - Types and Examples

Keras modules provide various predefined classes and functions for deep learning algorithms. In this Keras tutorial, we will learn various modules in Keras. We will study the features and few of the applications of these modules.

Keras Modules

Various Modules available in keras are:

  • Backend
  • Utils
  • Image Processing
  • Sequence Processing
  • Text Processing
  • Callback

#keras tutorials #keras modules #modules in keras #keras