
import logging
import botocore
from kotocore.session import Session

log = logging.getLogger(__name__)


class KambooConnection(object):
    """
    Kamboo connection with botocore session initialized
    """
    session = botocore.session.get_session()

    def __init__(self, service_name="ec2", region_name="us-east-1",
                 account_id=None,
                 credentials=None):
        self.region = region_name
        self.account_id = account_id
        self.credentials = credentials
        if self.credentials:
            self.session.set_credentials(**self.credentials)
        Connection = Session(session=self.session).get_connection(service_name)
        self.conn = Connection(region_name=self.region)


import logging
import botocore
from kotocore.session import Session

log = logging.getLogger(__name__)


class KambooConnection(object):
    """
    Kamboo connection with botocore session initialized
    """

    def __init__(self, service_name="ec2", region_name="us-east-1",
                 account_id=None,
                 credentials=None):
        self.session = botocore.session.get_session()
        self.service = service_name
        self.region = region_name
        self.account_id = account_id
        self.credentials = credentials
        if self.credentials:
            self.session.set_credentials(**self.credentials)
        Connection = Session(session=self.session).get_connection(service_name)
        self.conn = Connection(region_name=self.region)

    def __repr__(self):
        return "KambooConnection: [%s, %s, %s]" % (self.account_id,
                                                   self.region,
                                                   self.service)

Fix the issue: "session" shared in different connections
Fix the issue: "session" shared in different connections

  
  import logging
  import botocore
  from kotocore.session import Session
  
  log = logging.getLogger(__name__)
  
  
  class KambooConnection(object):
      """
      Kamboo connection with botocore session initialized
      """
-     session = botocore.session.get_session()
  
      def __init__(self, service_name="ec2", region_name="us-east-1",
                   account_id=None,
                   credentials=None):
+         self.session = botocore.session.get_session()
+         self.service = service_name
          self.region = region_name
          self.account_id = account_id
          self.credentials = credentials
          if self.credentials:
              self.session.set_credentials(**self.credentials)
          Connection = Session(session=self.session).get_connection(service_name)
          self.conn = Connection(region_name=self.region)
  
+     def __repr__(self):
+         return "KambooConnection: [%s, %s, %s]" % (self.account_id,
+                                                    self.region,
+                                                    self.service)
+ 
Fix the issue: "session" shared in different connections
## Code Before:

import logging
import botocore
from kotocore.session import Session

log = logging.getLogger(__name__)


class KambooConnection(object):
    """
    Kamboo connection with botocore session initialized
    """
    session = botocore.session.get_session()

    def __init__(self, service_name="ec2", region_name="us-east-1",
                 account_id=None,
                 credentials=None):
        self.region = region_name
        self.account_id = account_id
        self.credentials = credentials
        if self.credentials:
            self.session.set_credentials(**self.credentials)
        Connection = Session(session=self.session).get_connection(service_name)
        self.conn = Connection(region_name=self.region)

## Instruction:
Fix the issue: "session" shared in different connections
## Code After:

import logging
import botocore
from kotocore.session import Session

log = logging.getLogger(__name__)


class KambooConnection(object):
    """
    Kamboo connection with botocore session initialized
    """

    def __init__(self, service_name="ec2", region_name="us-east-1",
                 account_id=None,
                 credentials=None):
        self.session = botocore.session.get_session()
        self.service = service_name
        self.region = region_name
        self.account_id = account_id
        self.credentials = credentials
        if self.credentials:
            self.session.set_credentials(**self.credentials)
        Connection = Session(session=self.session).get_connection(service_name)
        self.conn = Connection(region_name=self.region)

    def __repr__(self):
        return "KambooConnection: [%s, %s, %s]" % (self.account_id,
                                                   self.region,
                                                   self.service)
