This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import time | |
import socket | |
# Create connection with the server on specific port | |
sock = socket.socket() | |
sock.connect((sys.argv[2], int(sys.argv[3]))) | |
address = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is the improved version of the code given in the article | |
https://towardsdatascience.com/understanding-lamport-timestamps-with-pythons-multiprocessing-library-12a6427881c6 | |
Shows three communicating processes with the vector clock for synchronization. | |
Result of running this code is: | |
Final vector in A is [7, 8, 3] | |
Final vector in B is [4, 8, 3] | |
Final vector in C is [1, 5, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tag can be string or a function if we parse the functional component | |
type Tag = string | ((props: any, children: any[]) => JSX.Element); | |
// Attributes of the element – object or null | |
type Props = Record<string, string> | null; | |
// Element children – return value from the h() | |
type Children = (Node | string)[]; | |
export const h = (tag: Tag, props: Props, ...children: Children) => { |