Example #1
0
from com.abc.banking.account import Account
from com.abc.banking.overdrafterror import OverdraftError
from traceback import print_exc

a = Account(acc_name='mehul', acc_type='Savings', acc_balance=10000)

try:
    ub = a.withdraw(900)
except OverdraftError:
    print_exc()
except ValueError:
    print_exc()
else:
    print(ub)

''' try:
    ub = a.withdraw(-4500)
except Exception:
    # catch all exception block
    print_exc() ''' # avoid it
from com.abc.banking.account import Account
from com.abc.banking.exceptions.min_bal_error import MinBalError

from traceback import print_exc

a1 = Account('mehul', 'savings', 10000)

try:
    print(a1.withdraw(8000))
except MinBalError:
    print('Min bal not mantained')
    print_exc()
except ValueError:
    print_exc()
from com.abc.banking.account import Account
from multiprocessing import Process, Queue
from threading import Thread

a = Account('chopras', 'current', 10000)

banking_queue = Queue(maxsize=10)  # bound the queue to at the max 10 messages
no_of_withdrawls = 0


# Producer
class WithdrawlInitiationthread(Thread):
    def __init__(self, name, amt):
        super().__init__(name=name)
        self.amt = amt

    def run(self):
        banking_queue.put((self.name, self.amt))


# Consumer
class Withdrawlprocess(Process):
    def run(self):
        while True:
            item = banking_queue.get()
            # transaction starts
            print('Opening balance as seen by {0} is {1}'.format(
                item[0], a.acc_balance))
            ub = a.withdraw(item[1])
            print('Updated balance as seen by {0} is {1}'.format(item[0], ub))
Example #4
0
from com.abc.banking.account import Account
from com.abc.banking.minbalerror import MinBalNotMaintainedError
from traceback import print_exc

a = Account(acc_name='mehul chopra', acc_no=1234, acc_balance=10000)

try:
  ub = a.withdraw(500000)
except MinBalNotMaintainedError:
  # print traceback
  print_exc()
except ValueError:
  print_exc()
else:
  print(ub)


# avoid this
''' try:
  ub = a.withdraw(9500)
except Exception:
  # catch all exception block
  print_exc() '''