// Outputs: // We do cleanup here // TypeError: Error: Thrown from thisThrows() // at myFunctionThatCatches (/repo/error_stacktrace_1.js:9:15) <-- Error points to our try catch block // at run (/repo/error_stacktrace_1.js:17:15) // at Object.<anonymous> (/repo/error_stacktrace_1.js:23:1)
// Outputs: // We do cleanup here // Error: Thrown from thisThrows() // at thisThrows (/repo/error_stacktrace_2.js:2:11) <-- Notice we now point to the origin of the actual error // at myFunctionThatCatches (/repo/error_stacktrace_2.js:7:16) // at run (/repo/error_stacktrace_2.js:18:15) // at Object.<anonymous> (/repo/error_stacktrace_2.js:24:1)
$ sudo pvdisplay --- Physical volume --- PV Name /dev/vda3 VG Name ubuntu-vg PV Size <8.25 GiB / not usable 0 Allocatable yes (but full) PE Size 4.00 MiB Total PE 2111 Free PE 0 Allocated PE 2111 PV UUID 96Cnvs-1rYe-xWk8-lB2V-cLSd-ALqk-4ujiPc --- Physical volume --- PV Name /dev/vdb VG Name ubuntu-vg PV Size 50.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12799 Free PE 0 Allocated PE 12799 PV UUID Hle3gv-3FNW-jkoe-dRFf-CwWd-pdJx-MWy3Ad
$ sudo vgextend ubuntu-vg /dev/vdc Volume group "ubuntu-vg" successfully extended
扩展LV大小以包含100%的新磁盘
1 2 3
$ sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv Size of logical volume ubuntu-vg/ubuntu-lv changed from 58.24 GiB (14910 extents) to <558.24 GiB (142909 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized.
现在需要调整文件系统的大小以匹配新的大小
1 2 3 4 5
$ sudo resize2fs -p /dev/ubuntu-vg/ubuntu-lv resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required old_desc_blocks = 8, new_desc_blocks = 70 The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 146338816 (4k) blocks long.
STREAM_DELAY = 1# second RETRY_TIMEOUT = 15000# milisecond
@app.get('/stream') asyncdefmessage_stream(request: Request): defnew_messages(): # Add logic here to check for new messages yield'Hello World' asyncdefevent_generator(): whileTrue: # If client closes connection, stop sending events ifawait request.is_disconnected(): break
# Checks for new messages and return them to client if any if new_messages(): yield { "event": "new_message", "id": "message_id", "retry": RETRY_TIMEOUT, "data": "message_content" }
# urllib.parse.urlencode(query, doseq=False, [...]) # Convert a mapping object or a sequence of two-element tuples, which may contain str or bytes objects, to a percent-encoded ASCII text string. # Example from urllib.parse import urlencode urlencode({'pram1': 'foo', 'param2': 'bar'}) # pram1=foo¶m2=bar
Python2.x
1 2 3 4
from urllib import urlencode
data = {'name': 'Desmond Lua', 'age': 40} query_string = urlencode(data)
Python2 和Python3的兼容写法
1 2 3 4 5 6
try: #python2 from urllib import urlencode except ImportError: #python3 from urllib.parse import urlencode
#python program to convert #URL parameters to dictionary items # initializing string test_str = 'gfg=4&is=5&best=yes'
# printing original string print("The original string is : " + str(test_str))
# getting all params res = dict() x=test_str.split("&") for i in x: a,b=i.split("=") # assigning keys with values res[a]=[b] # printing result print("The parsed URL Params : " + str(res))
#The original string is : gfg=4&is=5&best=yes # The parsed URL Params : {'gfg': ['4'], 'is': ['5'], 'best': ['yes']}